use of javax.swing.JMenuBar in project JMRI by JMRI.
the class AudioTableAction method setMenuBar.
@Override
public void setMenuBar(BeanTableFrame f) {
JMenuBar menuBar = f.getJMenuBar();
ResourceBundle rbapps = ResourceBundle.getBundle("apps.AppsBundle");
MenuElement[] subElements;
JMenu fileMenu = null;
for (int i = 0; i < menuBar.getMenuCount(); i++) {
if (menuBar.getComponent(i) instanceof JMenu) {
if (((JMenu) menuBar.getComponent(i)).getText().equals(Bundle.getMessage("MenuFile"))) {
fileMenu = menuBar.getMenu(i);
}
}
}
if (fileMenu == null) {
return;
}
subElements = fileMenu.getSubElements();
for (MenuElement subElement : subElements) {
MenuElement[] popsubElements = subElement.getSubElements();
for (MenuElement popsubElement : popsubElements) {
if (popsubElement instanceof JMenuItem) {
if (((JMenuItem) popsubElement).getText().equals(rbapps.getString("PrintTable"))) {
JMenuItem printMenu = (JMenuItem) popsubElement;
fileMenu.remove(printMenu);
break;
}
}
}
}
fileMenu.add(atp.getPrintItem());
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class SignalMastLogicTableAction method setMenuBar.
/**
* Insert a table specific Tools menu.
* Account for the Window and Help menus, which are already added to the menu bar
* as part of the creation of the JFrame, by adding the Tools menu 2 places earlier
* unless the table is part of the ListedTableFrame, that adds the Help menu later on.
* @param f the JFrame of this table
*/
@Override
public void setMenuBar(BeanTableFrame f) {
// needed for anonymous ActionListener class
final jmri.util.JmriJFrame finalF = f;
JMenuBar menuBar = f.getJMenuBar();
// count the number of menus to insert the TableMenu before 'Window' and 'Help'
int pos = menuBar.getMenuCount() - 1;
int offset = 1;
log.debug("setMenuBar number of menu items = " + pos);
for (int i = 0; i <= pos; i++) {
if (menuBar.getComponent(i) instanceof JMenu) {
if (((JMenu) menuBar.getComponent(i)).getText().equals(Bundle.getMessage("MenuHelp"))) {
// correct for use as part of ListedTableAction where the Help Menu is not yet present
offset = -1;
}
}
}
JMenu pathMenu = new JMenu(Bundle.getMessage("MenuTools"));
menuBar.add(pathMenu, pos + offset);
JMenuItem item = new JMenuItem(Bundle.getMessage("MenuItemAutoGen"));
pathMenu.add(item);
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
autoCreatePairs(finalF);
}
});
item = new JMenuItem(Bundle.getMessage("MenuItemAutoGenSections"));
pathMenu.add(item);
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
((jmri.managers.DefaultSignalMastLogicManager) InstanceManager.getDefault(jmri.SignalMastLogicManager.class)).generateSection();
JOptionPane.showMessageDialog(null, Bundle.getMessage("SectionGenerationComplete"));
}
});
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class SignalMastTableAction method setMenuBar.
/**
* Insert a table specific Tools menu.
* Account for the Window and Help menus, which are already added to the menu bar
* as part of the creation of the JFrame, by adding the Tools menu 2 places earlier
* unless the table is part of the ListedTableFrame, that adds the Help menu later on.
* @param f the JFrame of this table
*/
@Override
public void setMenuBar(BeanTableFrame f) {
JMenuBar menuBar = f.getJMenuBar();
// count the number of menus to insert the TableMenu before 'Window' and 'Help'
int pos = menuBar.getMenuCount() - 1;
int offset = 1;
log.debug("setMenuBar number of menu items = " + pos);
for (int i = 0; i <= pos; i++) {
if (menuBar.getComponent(i) instanceof JMenu) {
if (((JMenu) menuBar.getComponent(i)).getText().equals(Bundle.getMessage("MenuHelp"))) {
// correct for use as part of ListedTableAction where the Help Menu is not yet present
offset = -1;
}
}
}
JMenu pathMenu = new JMenu(Bundle.getMessage("MenuTools"));
menuBar.add(pathMenu, pos + offset);
JMenuItem item = new JMenuItem(Bundle.getMessage("MenuItemRepeaters"));
pathMenu.add(item);
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
jmri.jmrit.beantable.signalmast.SignalMastRepeaterJFrame frame = new jmri.jmrit.beantable.signalmast.SignalMastRepeaterJFrame();
frame.setVisible(true);
}
});
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class SwitchboardEditor method makeFrame.
/**
* Create sequence of panels, etc. for layout: JFrame contains its
* ContentPane which contains a JPanel with BoxLayout (p1) which contains a
* JScollPane (js) which contains the targetPane.
*
* @param name name for the Switchboard
*/
public JmriJFrame makeFrame(String name) {
JmriJFrame targetFrame = new JmriJFrame(name);
targetFrame.setVisible(true);
JMenuBar menuBar = new JMenuBar();
JMenu editMenu = new JMenu(Bundle.getMessage("MenuEdit"));
menuBar.add(editMenu);
editMenu.add(new AbstractAction(Bundle.getMessage("OpenEditor")) {
@Override
public void actionPerformed(ActionEvent e) {
setVisible(true);
}
});
targetFrame.setJMenuBar(menuBar);
targetFrame.addHelpMenu("package.jmri.jmrit.display.SwitchboardEditor", true);
return targetFrame;
}
use of javax.swing.JMenuBar in project JMRI by JMRI.
the class WarrantTableFrame method initComponents.
/**
* By default, Swing components should be created an installed in this
* method, rather than in the ctor itself.
*/
@Override
public void initComponents() throws Exception {
//Casts at getTableCellEditorComponent() now fails with 3.0 ??
JTable table = new JTable(_model);
ComboBoxCellEditor comboEd;
TableRowSorter<WarrantTableModel> sorter = new TableRowSorter<>(_model);
comboEd = new ComboBoxCellEditor(new JComboBox<>());
table.setRowSorter(sorter);
// Use XTableColumnModel so we can control which columns are visible
XTableColumnModel tcm = new XTableColumnModel();
table.setColumnModel(tcm);
table.getTableHeader().setReorderingAllowed(true);
table.createDefaultColumnsFromModel();
_model.addHeaderListener(table);
table.setDefaultRenderer(Boolean.class, new ButtonRenderer());
table.setDefaultRenderer(JComboBox.class, new jmri.jmrit.symbolicprog.ValueRenderer());
table.setDefaultEditor(JComboBox.class, new jmri.jmrit.symbolicprog.ValueEditor());
JComboBox<String> box = new JComboBox<>(controls);
box.setFont(new Font(null, Font.PLAIN, 12));
table.getColumnModel().getColumn(WarrantTableModel.CONTROL_COLUMN).setCellEditor(new DefaultCellEditor(box));
table.getColumnModel().getColumn(WarrantTableModel.ROUTE_COLUMN).setCellEditor(comboEd);
table.getColumnModel().getColumn(WarrantTableModel.ALLOCATE_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
table.getColumnModel().getColumn(WarrantTableModel.ALLOCATE_COLUMN).setCellRenderer(new ButtonRenderer());
table.getColumnModel().getColumn(WarrantTableModel.DEALLOC_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
table.getColumnModel().getColumn(WarrantTableModel.DEALLOC_COLUMN).setCellRenderer(new ButtonRenderer());
table.getColumnModel().getColumn(WarrantTableModel.SET_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
table.getColumnModel().getColumn(WarrantTableModel.SET_COLUMN).setCellRenderer(new ButtonRenderer());
table.getColumnModel().getColumn(WarrantTableModel.AUTO_RUN_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
table.getColumnModel().getColumn(WarrantTableModel.AUTO_RUN_COLUMN).setCellRenderer(new ButtonRenderer());
table.getColumnModel().getColumn(WarrantTableModel.MANUAL_RUN_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
table.getColumnModel().getColumn(WarrantTableModel.MANUAL_RUN_COLUMN).setCellRenderer(new ButtonRenderer());
table.getColumnModel().getColumn(WarrantTableModel.EDIT_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
table.getColumnModel().getColumn(WarrantTableModel.EDIT_COLUMN).setCellRenderer(new ButtonRenderer());
table.getColumnModel().getColumn(WarrantTableModel.DELETE_COLUMN).setCellEditor(new ButtonEditor(new JButton()));
table.getColumnModel().getColumn(WarrantTableModel.DELETE_COLUMN).setCellRenderer(new ButtonRenderer());
//table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
for (int i = 0; i < _model.getColumnCount(); i++) {
int width = _model.getPreferredWidth(i);
table.getColumnModel().getColumn(i).setPreferredWidth(width);
}
tcm.setColumnVisible(tcm.getColumnByModelIndex(WarrantTableModel.MANUAL_RUN_COLUMN), false);
_rowHeight = box.getPreferredSize().height;
table.setRowHeight(_rowHeight);
table.setDragEnabled(true);
table.setTransferHandler(new jmri.util.DnDTableExportHandler());
_tablePane = new JScrollPane(table);
JPanel tablePanel = new JPanel();
tablePanel.setLayout(new BoxLayout(tablePanel, BoxLayout.Y_AXIS));
tablePanel.add(Box.createVerticalGlue());
JLabel title = new JLabel(Bundle.getMessage("ShowWarrants"));
tablePanel.add(title);
tablePanel.add(_tablePane);
JPanel bottom = new JPanel();
JPanel panel = new JPanel();
JButton nxButton = new JButton(Bundle.getMessage("CreateNXWarrant"));
nxButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
nxAction();
}
});
panel.add(nxButton);
panel.add(Box.createGlue());
panel.add(new JLabel("status"));
_status.addMouseListener(this);
_status.setBackground(Color.white);
_status.setFont(_status.getFont().deriveFont(Font.BOLD));
_status.setEditable(false);
setStatusText(BLANK.substring(0, 90), null, false);
panel.add(_status);
JButton haltAllButton = new JButton(Bundle.getMessage("HaltAllTrains"));
haltAllButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
haltAllAction();
}
});
haltAllButton.setForeground(Color.RED);
panel.add(Box.createGlue());
panel.add(haltAllButton);
///
bottom.add(panel);
tablePanel.add(bottom);
addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
dispose();
}
});
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
fileMenu.add(new jmri.configurexml.SaveMenu());
menuBar.add(fileMenu);
JMenu warrantMenu = new JMenu(Bundle.getMessage("MenuWarrant"));
warrantMenu.add(new AbstractAction(Bundle.getMessage("ConcatWarrants")) {
@Override
public void actionPerformed(ActionEvent e) {
concatMenuAction();
}
});
warrantMenu.add(new jmri.jmrit.logix.WarrantTableAction("CreateWarrant"));
warrantMenu.add(WarrantTableAction._trackerTable);
warrantMenu.add(new AbstractAction(Bundle.getMessage("CreateNXWarrant")) {
@Override
public void actionPerformed(ActionEvent e) {
nxAction();
}
});
warrantMenu.add(WarrantTableAction.makeLogMenu());
menuBar.add(warrantMenu);
setJMenuBar(menuBar);
addHelpMenu("package.jmri.jmrit.logix.WarrantTable", true);
getContentPane().add(tablePanel);
// setLocation(50,0);
pack();
}
Aggregations