use of javax.swing.table.TableColumnModel in project jdk8u_jdk by JetBrains.
the class XMBeanAttributes method updateColumnWidth.
private void updateColumnWidth(int col1Width, int col2Width) {
TableColumnModel colModel = getColumnModel();
//Get the column at index pColumn, and set its preferred width.
col1Width = col1Width * 7;
col2Width = col2Width * 7;
if (col1Width + col2Width < (int) getPreferredScrollableViewportSize().getWidth())
col2Width = (int) getPreferredScrollableViewportSize().getWidth() - col1Width;
colModel.getColumn(NAME_COLUMN).setPreferredWidth(50);
}
use of javax.swing.table.TableColumnModel in project jabref by JabRef.
the class StyleSelectDialog method setupTable.
private void setupTable() {
styles = new BasicEventList<>();
EventList<OOBibStyle> sortedStyles = new SortedList<>(styles);
tableModel = (DefaultEventTableModel<OOBibStyle>) GlazedListsSwing.eventTableModelWithThreadProxyList(sortedStyles, new StyleTableFormat());
table = new JTable(tableModel);
TableColumnModel cm = table.getColumnModel();
cm.getColumn(0).setPreferredWidth(100);
cm.getColumn(1).setPreferredWidth(200);
cm.getColumn(2).setPreferredWidth(80);
selectionModel = (DefaultEventSelectionModel<OOBibStyle>) GlazedListsSwing.eventSelectionModelWithThreadProxyList(sortedStyles);
table.setSelectionModel(selectionModel);
table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent mouseEvent) {
if (mouseEvent.isPopupTrigger()) {
tablePopup(mouseEvent);
}
}
@Override
public void mouseReleased(MouseEvent mouseEvent) {
if (mouseEvent.isPopupTrigger()) {
tablePopup(mouseEvent);
}
}
});
selectionModel.getSelected().addListEventListener(new EntrySelectionListener());
}
use of javax.swing.table.TableColumnModel in project jabref by JabRef.
the class SearchResultFrame method setWidths.
/**
* Set column widths according to which field is shown, and lock icon columns
* to a suitable width.
*/
private void setWidths() {
TableColumnModel cm = entryTable.getColumnModel();
for (int i = 0; i < PAD + FIELDS.length; i++) {
switch(i) {
case FILE_COL:
case URL_COL:
cm.getColumn(i).setPreferredWidth(GUIGlobals.WIDTH_ICON_COL);
cm.getColumn(i).setMinWidth(GUIGlobals.WIDTH_ICON_COL);
cm.getColumn(i).setMaxWidth(GUIGlobals.WIDTH_ICON_COL);
break;
case DATABASE_COL:
{
int width = InternalBibtexFields.getFieldLength(FieldName.AUTHOR);
cm.getColumn(i).setPreferredWidth(width);
break;
}
default:
{
int width = InternalBibtexFields.getFieldLength(FIELDS[i - PAD]);
cm.getColumn(i).setPreferredWidth(width);
break;
}
}
}
}
use of javax.swing.table.TableColumnModel in project JMRI by JMRI.
the class LocoDataModel method setColumnToHoldEStopButton.
void setColumnToHoldEStopButton(JTable slotTable, int column) {
TableColumnModel tcm = slotTable.getColumnModel();
// install the button renderers & editors in this column
ButtonRenderer buttonRenderer = new ButtonRenderer();
tcm.getColumn(column).setCellRenderer(buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton()) {
@Override
public void mousePressed(MouseEvent e) {
stopCellEditing();
}
};
tcm.getColumn(column).setCellEditor(buttonEditor);
// ensure the table rows, columns have enough room for buttons
slotTable.setRowHeight(new JButton(" " + getValueAt(1, column)).getPreferredSize().height);
slotTable.getColumnModel().getColumn(column).setPreferredWidth(new JButton(" " + getValueAt(1, column)).getPreferredSize().width);
}
use of javax.swing.table.TableColumnModel in project JMRI by JMRI.
the class LocoDataModel method setColumnToHoldButton.
void setColumnToHoldButton(JTable slotTable, int column) {
TableColumnModel tcm = slotTable.getColumnModel();
// install the button renderers & editors in this column
ButtonRenderer buttonRenderer = new ButtonRenderer();
tcm.getColumn(column).setCellRenderer(buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton());
tcm.getColumn(column).setCellEditor(buttonEditor);
// ensure the table rows, columns have enough room for buttons
slotTable.setRowHeight(new JButton(" " + getValueAt(1, column)).getPreferredSize().height);
slotTable.getColumnModel().getColumn(column).setPreferredWidth(new JButton(" " + getValueAt(1, column)).getPreferredSize().width);
}
Aggregations