use of javax.swing.table.TableColumn in project JMRI by JMRI.
the class XTableColumnModel method getColumnIndex.
/**
* Returns the position of the first column whose identifier equals
* <code>identifier</code>. Position is the the index in all visible columns
* if <code>onlyVisible</code> is true or else the index in all columns.
*
* @param identifier the identifier object to search for
* @param onlyVisible if set searches only visible columns
*
* @return the index of the first column whose identifier equals
* <code>identifier</code>
*
* @exception IllegalArgumentException if <code>identifier</code> is
* <code>null</code>, or if no
* <code>TableColumn</code> has this
* <code>identifier</code>
* @see #getColumn
*/
public int getColumnIndex(Object identifier, boolean onlyVisible) {
if (identifier == null) {
throw new IllegalArgumentException("Identifier is null");
}
Vector<TableColumn> columns = (onlyVisible ? tableColumns : allTableColumns);
int noColumns = columns.size();
TableColumn column;
for (int columnIndex = 0; columnIndex < noColumns; ++columnIndex) {
column = columns.get(columnIndex);
if (identifier.equals(column.getIdentifier())) {
return columnIndex;
}
}
throw new IllegalArgumentException("Identifier not found");
}
use of javax.swing.table.TableColumn in project JMRI by JMRI.
the class LogixTableAction method createModel.
// *********** Methods for Logix Table Window ********************
/**
* Create the JTable DataModel, along with the changes (overrides of
* BeanTableDataModel) for the specific case of a Logix table.
* <p>
* Note: Table Models for the Conditional table in the Edit Logix window,
* and the State Variable table in the Edit Conditional window are at
* the end of this module.
*/
@Override
protected void createModel() {
m = new BeanTableDataModel() {
// overlay the state column with the edit column
public static final int ENABLECOL = VALUECOL;
public static final int EDITCOL = DELETECOL;
protected String enabledString = Bundle.getMessage("ColumnHeadEnabled");
@Override
public String getColumnName(int col) {
if (col == EDITCOL) {
// no heading on "Edit"
return "";
}
if (col == ENABLECOL) {
return enabledString;
}
return super.getColumnName(col);
}
@Override
public Class<?> getColumnClass(int col) {
if (col == EDITCOL) {
return String.class;
}
if (col == ENABLECOL) {
return Boolean.class;
}
return super.getColumnClass(col);
}
@Override
public int getPreferredWidth(int col) {
// override default value for SystemName and UserName columns
if (col == SYSNAMECOL) {
return new JTextField(12).getPreferredSize().width;
}
if (col == USERNAMECOL) {
return new JTextField(17).getPreferredSize().width;
}
if (col == EDITCOL) {
return new JTextField(12).getPreferredSize().width;
}
if (col == ENABLECOL) {
return new JTextField(5).getPreferredSize().width;
}
return super.getPreferredWidth(col);
}
@Override
public boolean isCellEditable(int row, int col) {
if (col == EDITCOL) {
return true;
}
if (col == ENABLECOL) {
return true;
}
return super.isCellEditable(row, col);
}
@Override
public Object getValueAt(int row, int col) {
if (col == EDITCOL) {
return Bundle.getMessage("ButtonSelect");
} else if (col == ENABLECOL) {
Logix logix = (Logix) getBySystemName((String) getValueAt(row, SYSNAMECOL));
if (logix == null) {
return null;
}
return Boolean.valueOf(logix.getEnabled());
} else {
return super.getValueAt(row, col);
}
}
@Override
public void setValueAt(Object value, int row, int col) {
if (col == EDITCOL) {
// set up to edit
String sName = (String) getValueAt(row, SYSNAMECOL);
if (Bundle.getMessage("ButtonEdit").equals(value)) {
editPressed(sName);
} else if (rbx.getString("BrowserButton").equals(value)) {
conditionalRowNumber = row;
browserPressed(sName);
} else if (Bundle.getMessage("ButtonCopy").equals(value)) {
copyPressed(sName);
} else if (Bundle.getMessage("ButtonDelete").equals(value)) {
deletePressed(sName);
}
} else if (col == ENABLECOL) {
// alternate
Logix x = (Logix) getBySystemName((String) getValueAt(row, SYSNAMECOL));
boolean v = x.getEnabled();
x.setEnabled(!v);
} else {
super.setValueAt(value, row, col);
}
}
/**
* Delete the bean after all the checking has been done.
* <p>
* Deactivates the Logix and remove it's conditionals.
*
* @param bean of the Logix to delete
*/
@Override
void doDelete(NamedBean bean) {
Logix l = (Logix) bean;
l.deActivateLogix();
// delete the Logix and all its Conditionals
_logixManager.deleteLogix(l);
}
@Override
protected boolean matchPropertyName(java.beans.PropertyChangeEvent e) {
if (e.getPropertyName().equals(enabledString)) {
return true;
}
return super.matchPropertyName(e);
}
@Override
public Manager getManager() {
return InstanceManager.getDefault(jmri.LogixManager.class);
}
@Override
public NamedBean getBySystemName(String name) {
return InstanceManager.getDefault(jmri.LogixManager.class).getBySystemName(name);
}
@Override
public NamedBean getByUserName(String name) {
return InstanceManager.getDefault(jmri.LogixManager.class).getByUserName(name);
}
@Override
protected String getMasterClassName() {
return getClassName();
}
@Override
public void configureTable(JTable table) {
table.setDefaultRenderer(Boolean.class, new EnablingCheckboxRenderer());
table.setDefaultRenderer(JComboBox.class, new jmri.jmrit.symbolicprog.ValueRenderer());
table.setDefaultEditor(JComboBox.class, new jmri.jmrit.symbolicprog.ValueEditor());
super.configureTable(table);
}
/**
* Replace delete button with comboBox to edit/delete/copy/select Logix.
*
* @param table name of the Logix JTable holding the column
*/
@Override
protected void configDeleteColumn(JTable table) {
JComboBox<String> editCombo = new JComboBox<String>();
editCombo.addItem(Bundle.getMessage("ButtonSelect"));
editCombo.addItem(Bundle.getMessage("ButtonEdit"));
editCombo.addItem(rbx.getString("BrowserButton"));
editCombo.addItem(Bundle.getMessage("ButtonCopy"));
editCombo.addItem(Bundle.getMessage("ButtonDelete"));
TableColumn col = table.getColumnModel().getColumn(BeanTableDataModel.DELETECOL);
col.setCellEditor(new DefaultCellEditor(editCombo));
}
// Not needed - here for interface compatibility
@Override
public void clickOn(NamedBean t) {
}
@Override
public String getValue(String s) {
return "";
}
@Override
protected String getBeanType() {
return Bundle.getMessage("BeanNameLogix");
}
};
}
use of javax.swing.table.TableColumn in project JMRI by JMRI.
the class LogixTableAction method makeEditLogixWindow.
/**
* Create and/or initialize the Edit Logix pane.
*/
void makeEditLogixWindow() {
// Setup the name box components.
setNameBoxListeners();
//if (log.isDebugEnabled()) log.debug("makeEditLogixWindow ");
editUserName.setText(_curLogix.getUserName());
// clear conditional table if needed
if (conditionalTableModel != null) {
conditionalTableModel.fireTableStructureChanged();
}
inEditMode = true;
if (editLogixFrame == null) {
editLogixFrame = new JmriJFrame(rbx.getString("TitleEditLogix"), false, false);
editLogixFrame.addHelpMenu("package.jmri.jmrit.beantable.LogixAddEdit", true);
editLogixFrame.setLocation(100, 30);
Container contentPane = editLogixFrame.getContentPane();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
JPanel panel1 = new JPanel();
panel1.setLayout(new FlowLayout());
JLabel systemNameLabel = new JLabel(Bundle.getMessage("ColumnSystemName") + ":");
panel1.add(systemNameLabel);
JLabel fixedSystemName = new JLabel(_curLogix.getSystemName());
panel1.add(fixedSystemName);
contentPane.add(panel1);
JPanel panel2 = new JPanel();
panel2.setLayout(new FlowLayout());
JLabel userNameLabel = new JLabel(Bundle.getMessage("ColumnUserName") + ":");
panel2.add(userNameLabel);
panel2.add(editUserName);
editUserName.setToolTipText(rbx.getString("LogixUserNameHint2"));
contentPane.add(panel2);
// add table of Conditionals
JPanel pctSpace = new JPanel();
pctSpace.setLayout(new FlowLayout());
pctSpace.add(new JLabel(" "));
contentPane.add(pctSpace);
JPanel pTitle = new JPanel();
pTitle.setLayout(new FlowLayout());
pTitle.add(new JLabel(rbx.getString("ConditionalTableTitle")));
contentPane.add(pTitle);
// initialize table of conditionals
conditionalTableModel = new ConditionalTableModel();
JTable conditionalTable = new JTable(conditionalTableModel);
conditionalTable.setRowSelectionAllowed(false);
TableColumnModel conditionalColumnModel = conditionalTable.getColumnModel();
TableColumn sNameColumn = conditionalColumnModel.getColumn(ConditionalTableModel.SNAME_COLUMN);
sNameColumn.setResizable(true);
sNameColumn.setMinWidth(100);
sNameColumn.setPreferredWidth(130);
TableColumn uNameColumn = conditionalColumnModel.getColumn(ConditionalTableModel.UNAME_COLUMN);
uNameColumn.setResizable(true);
uNameColumn.setMinWidth(210);
uNameColumn.setPreferredWidth(260);
TableColumn stateColumn = conditionalColumnModel.getColumn(ConditionalTableModel.STATE_COLUMN);
stateColumn.setResizable(true);
stateColumn.setMinWidth(50);
stateColumn.setMaxWidth(100);
TableColumn buttonColumn = conditionalColumnModel.getColumn(ConditionalTableModel.BUTTON_COLUMN);
// install button renderer and editor
ButtonRenderer buttonRenderer = new ButtonRenderer();
conditionalTable.setDefaultRenderer(JButton.class, buttonRenderer);
TableCellEditor buttonEditor = new ButtonEditor(new JButton());
conditionalTable.setDefaultEditor(JButton.class, buttonEditor);
JButton testButton = new JButton("XXXXXX");
conditionalTable.setRowHeight(testButton.getPreferredSize().height);
buttonColumn.setMinWidth(testButton.getPreferredSize().width);
buttonColumn.setMaxWidth(testButton.getPreferredSize().width);
buttonColumn.setResizable(false);
JScrollPane conditionalTableScrollPane = new JScrollPane(conditionalTable);
Dimension dim = conditionalTable.getPreferredSize();
dim.height = 450;
conditionalTableScrollPane.getViewport().setPreferredSize(dim);
contentPane.add(conditionalTableScrollPane);
// add message area between table and buttons
JPanel panel4 = new JPanel();
panel4.setLayout(new BoxLayout(panel4, BoxLayout.Y_AXIS));
JPanel panel41 = new JPanel();
panel41.setLayout(new FlowLayout());
panel41.add(status);
panel4.add(panel41);
JPanel panel42 = new JPanel();
panel42.setLayout(new FlowLayout());
// Conditional panel buttons - New Conditional
JButton newConditionalButton = new JButton(rbx.getString("NewConditionalButton"));
panel42.add(newConditionalButton);
newConditionalButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
newConditionalPressed(e);
}
});
newConditionalButton.setToolTipText(rbx.getString("NewConditionalButtonHint"));
// Conditional panel buttons - Reorder
JButton reorderButton = new JButton(rbx.getString("ReorderButton"));
panel42.add(reorderButton);
reorderButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
reorderPressed(e);
}
});
reorderButton.setToolTipText(rbx.getString("ReorderButtonHint"));
// Conditional panel buttons - Calculate
JButton calculateButton = new JButton(rbx.getString("CalculateButton"));
panel42.add(calculateButton);
calculateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
calculatePressed(e);
}
});
calculateButton.setToolTipText(rbx.getString("CalculateButtonHint"));
panel4.add(panel42);
Border panel4Border = BorderFactory.createEtchedBorder();
panel4.setBorder(panel4Border);
contentPane.add(panel4);
// add buttons at bottom of window
JPanel panel5 = new JPanel();
panel5.setLayout(new FlowLayout());
// Bottom Buttons - Done Logix
JButton done = new JButton(Bundle.getMessage("ButtonDone"));
panel5.add(done);
done.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
donePressed(e);
}
});
done.setToolTipText(rbx.getString("DoneButtonHint"));
// Delete Logix
JButton delete = new JButton(Bundle.getMessage("ButtonDelete"));
panel5.add(delete);
delete.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
deletePressed(e);
}
});
delete.setToolTipText(rbx.getString("DeleteLogixButtonHint"));
contentPane.add(panel5);
}
editLogixFrame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
if (inEditMode) {
donePressed(null);
} else {
finishDone();
}
}
});
editLogixFrame.pack();
editLogixFrame.setVisible(true);
}
use of javax.swing.table.TableColumn in project JMRI by JMRI.
the class DispatcherFrame method openDispatcherWindow.
void openDispatcherWindow() {
if (dispatcherFrame == null) {
dispatcherFrame = this;
dispatcherFrame.setTitle(Bundle.getMessage("TitleDispatcher"));
JMenuBar menuBar = new JMenuBar();
optionsMenu = new OptionsMenu(this);
menuBar.add(optionsMenu);
setJMenuBar(menuBar);
dispatcherFrame.addHelpMenu("package.jmri.jmrit.dispatcher.Dispatcher", true);
contentPane = dispatcherFrame.getContentPane();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
// set up active trains table
JPanel p11 = new JPanel();
p11.setLayout(new FlowLayout());
p11.add(new JLabel(Bundle.getMessage("ActiveTrainTableTitle")));
contentPane.add(p11);
JPanel p12 = new JPanel();
p12.setLayout(new FlowLayout());
activeTrainsTableModel = new ActiveTrainsTableModel();
JTable activeTrainsTable = new JTable(activeTrainsTableModel);
activeTrainsTable.setRowSelectionAllowed(false);
activeTrainsTable.setPreferredScrollableViewportSize(new java.awt.Dimension(950, 160));
TableColumnModel activeTrainsColumnModel = activeTrainsTable.getColumnModel();
TableColumn transitColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.TRANSIT_COLUMN);
transitColumn.setResizable(true);
transitColumn.setMinWidth(140);
transitColumn.setMaxWidth(220);
TableColumn trainColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.TRAIN_COLUMN);
trainColumn.setResizable(true);
trainColumn.setMinWidth(90);
trainColumn.setMaxWidth(160);
TableColumn typeColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.TYPE_COLUMN);
typeColumn.setResizable(true);
typeColumn.setMinWidth(130);
typeColumn.setMaxWidth(190);
TableColumn statusColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.STATUS_COLUMN);
statusColumn.setResizable(true);
statusColumn.setMinWidth(90);
statusColumn.setMaxWidth(140);
TableColumn modeColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.MODE_COLUMN);
modeColumn.setResizable(true);
modeColumn.setMinWidth(90);
modeColumn.setMaxWidth(140);
TableColumn allocatedColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.ALLOCATED_COLUMN);
allocatedColumn.setResizable(true);
allocatedColumn.setMinWidth(120);
allocatedColumn.setMaxWidth(200);
TableColumn nextSectionColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.NEXTSECTION_COLUMN);
nextSectionColumn.setResizable(true);
nextSectionColumn.setMinWidth(120);
nextSectionColumn.setMaxWidth(200);
TableColumn allocateButtonColumn = activeTrainsColumnModel.getColumn(ActiveTrainsTableModel.ALLOCATEBUTTON_COLUMN);
allocateButtonColumn.setCellEditor(new ButtonEditor(new JButton()));
allocateButtonColumn.setMinWidth(110);
allocateButtonColumn.setMaxWidth(190);
allocateButtonColumn.setResizable(false);
ButtonRenderer buttonRenderer = new ButtonRenderer();
activeTrainsTable.setDefaultRenderer(JButton.class, buttonRenderer);
JButton sampleButton = new JButton(Bundle.getMessage("AllocateButtonName"));
activeTrainsTable.setRowHeight(sampleButton.getPreferredSize().height);
allocateButtonColumn.setPreferredWidth((sampleButton.getPreferredSize().width) + 2);
JScrollPane activeTrainsTableScrollPane = new JScrollPane(activeTrainsTable);
p12.add(activeTrainsTableScrollPane, BorderLayout.CENTER);
contentPane.add(p12);
JPanel p13 = new JPanel();
p13.setLayout(new FlowLayout());
p13.add(addTrainButton = new JButton(Bundle.getMessage("InitiateTrain") + "..."));
addTrainButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!newTrainActive) {
atFrame.initiateTrain(e);
newTrainActive = true;
} else {
atFrame.showActivateFrame();
}
}
});
addTrainButton.setToolTipText(Bundle.getMessage("InitiateTrainButtonHint"));
p13.add(new JLabel(" "));
p13.add(new JLabel(" "));
p13.add(allocateExtraButton = new JButton(Bundle.getMessage("AllocateExtra") + "..."));
allocateExtraButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
allocateExtraSection(e);
}
});
allocateExtraButton.setToolTipText(Bundle.getMessage("AllocateExtraButtonHint"));
p13.add(new JLabel(" "));
p13.add(cancelRestartButton = new JButton(Bundle.getMessage("CancelRestart") + "..."));
cancelRestartButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!newTrainActive) {
cancelRestart(e);
} else if (restartingTrainsList.size() > 0) {
atFrame.showActivateFrame();
JOptionPane.showMessageDialog(dispatcherFrame, Bundle.getMessage("Message2"), Bundle.getMessage("MessageTitle"), JOptionPane.INFORMATION_MESSAGE);
} else {
atFrame.showActivateFrame();
}
}
});
cancelRestartButton.setToolTipText(Bundle.getMessage("CancelRestartButtonHint"));
p13.add(new JLabel(" "));
p13.add(terminateTrainButton = new JButton(Bundle.getMessage("TerminateTrain") + "..."));
terminateTrainButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!newTrainActive) {
terminateTrain(e);
} else if (activeTrainsList.size() > 0) {
atFrame.showActivateFrame();
JOptionPane.showMessageDialog(dispatcherFrame, Bundle.getMessage("Message1"), Bundle.getMessage("MessageTitle"), JOptionPane.INFORMATION_MESSAGE);
} else {
atFrame.showActivateFrame();
}
}
});
terminateTrainButton.setToolTipText(Bundle.getMessage("TerminateTrainButtonHint"));
contentPane.add(p13);
// set up pending allocations table
contentPane.add(new JSeparator());
JPanel p21 = new JPanel();
p21.setLayout(new FlowLayout());
p21.add(new JLabel(Bundle.getMessage("RequestedAllocationsTableTitle")));
contentPane.add(p21);
JPanel p22 = new JPanel();
p22.setLayout(new FlowLayout());
allocationRequestTableModel = new AllocationRequestTableModel();
JTable allocationRequestTable = new JTable(allocationRequestTableModel);
allocationRequestTable.setRowSelectionAllowed(false);
allocationRequestTable.setPreferredScrollableViewportSize(new java.awt.Dimension(950, 100));
TableColumnModel allocationRequestColumnModel = allocationRequestTable.getColumnModel();
TableColumn activeColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.ACTIVE_COLUMN);
activeColumn.setResizable(true);
activeColumn.setMinWidth(210);
activeColumn.setMaxWidth(260);
TableColumn priorityColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.PRIORITY_COLUMN);
priorityColumn.setResizable(true);
priorityColumn.setMinWidth(40);
priorityColumn.setMaxWidth(60);
TableColumn trainTypColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.TRAINTYPE_COLUMN);
trainTypColumn.setResizable(true);
trainTypColumn.setMinWidth(130);
trainTypColumn.setMaxWidth(190);
TableColumn sectionColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.SECTION_COLUMN);
sectionColumn.setResizable(true);
sectionColumn.setMinWidth(140);
sectionColumn.setMaxWidth(210);
TableColumn secStatusColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.STATUS_COLUMN);
secStatusColumn.setResizable(true);
secStatusColumn.setMinWidth(90);
secStatusColumn.setMaxWidth(150);
TableColumn occupancyColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.OCCUPANCY_COLUMN);
occupancyColumn.setResizable(true);
occupancyColumn.setMinWidth(80);
occupancyColumn.setMaxWidth(130);
TableColumn secLengthColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.SECTIONLENGTH_COLUMN);
secLengthColumn.setResizable(true);
secLengthColumn.setMinWidth(40);
secLengthColumn.setMaxWidth(60);
TableColumn allocateColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.ALLOCATEBUTTON_COLUMN);
allocateColumn.setCellEditor(new ButtonEditor(new JButton()));
allocateColumn.setMinWidth(90);
allocateColumn.setMaxWidth(170);
allocateColumn.setResizable(false);
allocationRequestTable.setDefaultRenderer(JButton.class, buttonRenderer);
sampleButton = new JButton(Bundle.getMessage("AllocateButton"));
allocationRequestTable.setRowHeight(sampleButton.getPreferredSize().height);
allocateColumn.setPreferredWidth((sampleButton.getPreferredSize().width) + 2);
TableColumn cancelButtonColumn = allocationRequestColumnModel.getColumn(AllocationRequestTableModel.CANCELBUTTON_COLUMN);
cancelButtonColumn.setCellEditor(new ButtonEditor(new JButton()));
cancelButtonColumn.setMinWidth(75);
cancelButtonColumn.setMaxWidth(170);
cancelButtonColumn.setResizable(false);
cancelButtonColumn.setPreferredWidth((sampleButton.getPreferredSize().width) + 2);
JScrollPane allocationRequestTableScrollPane = new JScrollPane(allocationRequestTable);
p22.add(allocationRequestTableScrollPane, BorderLayout.CENTER);
contentPane.add(p22);
// set up allocated sections table
contentPane.add(new JSeparator());
JPanel p30 = new JPanel();
p30.setLayout(new FlowLayout());
p30.add(new JLabel(Bundle.getMessage("AllocatedSectionsTitle") + " "));
autoReleaseBox = new JCheckBox(Bundle.getMessage("AutoReleaseBoxLabel"));
p30.add(autoReleaseBox);
autoReleaseBox.setToolTipText(Bundle.getMessage("AutoReleaseBoxHint"));
autoReleaseBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
handleAutoReleaseChanged(e);
}
});
// initiallize autoRelease to match autoAllocate
autoReleaseBox.setSelected(_AutoAllocate);
autoAllocateBox = new JCheckBox(Bundle.getMessage("AutoDispatchItem"));
p30.add(autoAllocateBox);
autoAllocateBox.setToolTipText(Bundle.getMessage("AutoAllocateBoxHint"));
autoAllocateBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
handleAutoAllocateChanged(e);
}
});
contentPane.add(p30);
autoAllocateBox.setSelected(_AutoAllocate);
JPanel p31 = new JPanel();
p31.setLayout(new FlowLayout());
allocatedSectionTableModel = new AllocatedSectionTableModel();
JTable allocatedSectionTable = new JTable(allocatedSectionTableModel);
allocatedSectionTable.setRowSelectionAllowed(false);
allocatedSectionTable.setPreferredScrollableViewportSize(new java.awt.Dimension(730, 200));
TableColumnModel allocatedSectionColumnModel = allocatedSectionTable.getColumnModel();
TableColumn activeAColumn = allocatedSectionColumnModel.getColumn(AllocatedSectionTableModel.ACTIVE_COLUMN);
activeAColumn.setResizable(true);
activeAColumn.setMinWidth(250);
activeAColumn.setMaxWidth(350);
TableColumn sectionAColumn = allocatedSectionColumnModel.getColumn(AllocatedSectionTableModel.SECTION_COLUMN);
sectionAColumn.setResizable(true);
sectionAColumn.setMinWidth(200);
sectionAColumn.setMaxWidth(350);
TableColumn occupancyAColumn = allocatedSectionColumnModel.getColumn(AllocatedSectionTableModel.OCCUPANCY_COLUMN);
occupancyAColumn.setResizable(true);
occupancyAColumn.setMinWidth(80);
occupancyAColumn.setMaxWidth(140);
TableColumn useStatusColumn = allocatedSectionColumnModel.getColumn(AllocatedSectionTableModel.USESTATUS_COLUMN);
useStatusColumn.setResizable(true);
useStatusColumn.setMinWidth(90);
useStatusColumn.setMaxWidth(150);
TableColumn releaseColumn = allocatedSectionColumnModel.getColumn(AllocatedSectionTableModel.RELEASEBUTTON_COLUMN);
releaseColumn.setCellEditor(new ButtonEditor(new JButton()));
releaseColumn.setMinWidth(90);
releaseColumn.setMaxWidth(170);
releaseColumn.setResizable(false);
allocatedSectionTable.setDefaultRenderer(JButton.class, buttonRenderer);
JButton sampleAButton = new JButton(Bundle.getMessage("ReleaseButton"));
allocatedSectionTable.setRowHeight(sampleAButton.getPreferredSize().height);
releaseColumn.setPreferredWidth((sampleAButton.getPreferredSize().width) + 2);
JScrollPane allocatedSectionTableScrollPane = new JScrollPane(allocatedSectionTable);
p31.add(allocatedSectionTableScrollPane, BorderLayout.CENTER);
contentPane.add(p31);
}
dispatcherFrame.pack();
dispatcherFrame.setVisible(true);
}
use of javax.swing.table.TableColumn in project JMRI by JMRI.
the class RosterTable method showTableHeaderPopup.
protected void showTableHeaderPopup(MouseEvent e) {
JPopupMenu popupMenu = new JPopupMenu();
for (int i = 0; i < columnModel.getColumnCount(false); i++) {
TableColumn tc = columnModel.getColumnByModelIndex(i);
JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(dataTable.getModel().getColumnName(i), columnModel.isColumnVisible(tc));
menuItem.addActionListener(new headerActionListener(tc));
popupMenu.add(menuItem);
}
popupMenu.show(e.getComponent(), e.getX(), e.getY());
}
Aggregations