}
public static GridField get(Component comp){
Component target = comp;
TableColumnModel colModel = null;
GridField gf = new GridField();
ArrayFieldTitleGrid action = ActionMgr.getAction(comp, ArrayFieldTitleGrid.class);
if (action != null) {
return action.getValue();
}
if (comp instanceof JScrollPane){ // if its a scroll pane
JTableHeader header = (JTableHeader)((JScrollPane)comp).getColumnHeader().getComponent(0);
colModel = header.getColumnModel();
} else { // must be a JTable
JTable table = (JTable)target;
colModel = table.getColumnModel();
}
for (int col = 0; col < colModel.getColumnCount(); col ++){
ArrayColumn ac = (ArrayColumn)colModel.getColumn(col);
DefaultTableCellRenderer cr = (DefaultTableCellRenderer)ac.getHeaderRenderer();
if (cr == null){
cr = new DefaultTableCellRenderer();
cr.setText(" ");
}
GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.CENTER;
gbc.fill = GridBagConstraints.NONE;
gbc.gridx = col;
gbc.gridy = 0;
gf.add(cr, gbc);
}
return gf;
}