Search in sources :

Example 81 with BoxLayout

use of javax.swing.BoxLayout in project JMRI by JMRI.

the class TrainsByCarTypeFrame method initComponents.

public void initComponents(String carType) {
    // load managers
    manager = TrainManager.instance();
    // general GUI config
    getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
    // Set up the panels
    JPanel pCarType = new JPanel();
    pCarType.setLayout(new GridBagLayout());
    pCarType.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Type")));
    addItem(pCarType, typeComboBox, 0, 0);
    addItem(pCarType, copyCheckBox, 1, 0);
    addItem(pCarType, textCarType, 2, 0);
    typeComboBox.setSelectedItem(carType);
    copyCheckBox.setToolTipText(Bundle.getMessage("TipCopyCarType"));
    pTrains = new JPanel();
    pTrains.setLayout(new GridBagLayout());
    JScrollPane trainPane = new JScrollPane(pTrains);
    trainPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    trainPane.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Trains")));
    updateTrains();
    JPanel pButtons = new JPanel();
    pButtons.setLayout(new GridBagLayout());
    pButtons.setBorder(BorderFactory.createEtchedBorder());
    addItem(pButtons, clearButton, 0, 0);
    addItem(pButtons, setButton, 1, 0);
    addItem(pButtons, saveButton, 2, 0);
    getContentPane().add(pCarType);
    getContentPane().add(trainPane);
    getContentPane().add(pButtons);
    // setup combo box
    addComboBoxAction(typeComboBox);
    // setup buttons
    addButtonAction(setButton);
    addButtonAction(clearButton);
    addButtonAction(saveButton);
    // setup checkbox
    addCheckBoxAction(copyCheckBox);
    manager.addPropertyChangeListener(this);
    CarTypes.instance().addPropertyChangeListener(this);
    // build menu
    JMenuBar menuBar = new JMenuBar();
    JMenu toolMenu = new JMenu(Bundle.getMessage("MenuTools"));
    toolMenu.add(new PrintTrainsByCarTypesAction(Bundle.getMessage("MenuItemPrintByType"), new Frame(), false, this));
    toolMenu.add(new PrintTrainsByCarTypesAction(Bundle.getMessage("MenuItemPreviewByType"), new Frame(), true, this));
    menuBar.add(toolMenu);
    setJMenuBar(menuBar);
    // NOI18N
    addHelpMenu("package.jmri.jmrit.operations.Operations_ModifyTrainsByCarType", true);
    setPreferredSize(null);
    pack();
    setMinimumSize(new Dimension(Control.panelWidth300, Control.panelHeight250));
    setTitle(Bundle.getMessage("TitleModifyTrains"));
    setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) OperationsFrame(jmri.jmrit.operations.OperationsFrame) Frame(java.awt.Frame) GridBagLayout(java.awt.GridBagLayout) BoxLayout(javax.swing.BoxLayout) Dimension(java.awt.Dimension) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 82 with BoxLayout

use of javax.swing.BoxLayout in project JMRI by JMRI.

the class TrainScriptFrame method initComponents.

public void initComponents(TrainEditFrame parent) {
    // Set up script options in a Scroll Pane..
    buildScriptPane = new JScrollPane(pBuildScript);
    buildScriptPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    buildScriptPane.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("ScriptsBeforeBuild")));
    afterBuildScriptPane = new JScrollPane(pAfterBuildScript);
    afterBuildScriptPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    afterBuildScriptPane.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("ScriptsAfterBuild")));
    moveScriptPane = new JScrollPane(pMoveScript);
    moveScriptPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    moveScriptPane.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("ScriptsWhenMoved")));
    terminationScriptPane = new JScrollPane(pTerminationScript);
    terminationScriptPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    terminationScriptPane.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("ScriptsWhenTerminated")));
    // remember who called us
    parent.setChildFrame(this);
    _train = parent._train;
    // load managers
    manager = TrainManager.instance();
    managerXml = TrainManagerXml.instance();
    getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
    // Layout the panel by rows
    JPanel p1 = new JPanel();
    p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
    // row 1a
    JPanel pName = new JPanel();
    pName.setLayout(new GridBagLayout());
    pName.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Name")));
    addItem(pName, trainName, 0, 0);
    // row 1b
    JPanel pDesc = new JPanel();
    pDesc.setLayout(new GridBagLayout());
    pDesc.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Description")));
    addItem(pDesc, trainDescription, 0, 0);
    p1.add(pName);
    p1.add(pDesc);
    // row 2
    updateBuildScriptPanel();
    // row 3
    updateAfterBuildScriptPanel();
    // row 4
    updateMoveScriptPanel();
    // row 6
    updateTerminationScriptPanel();
    // row 8 buttons
    JPanel pB = new JPanel();
    pB.setLayout(new GridBagLayout());
    addItem(pB, saveTrainButton, 3, 0);
    getContentPane().add(p1);
    getContentPane().add(buildScriptPane);
    getContentPane().add(afterBuildScriptPane);
    getContentPane().add(moveScriptPane);
    getContentPane().add(terminationScriptPane);
    getContentPane().add(pB);
    // setup buttons
    addButtonAction(addBuildScriptButton);
    addButtonAction(addAfterBuildScriptButton);
    addButtonAction(addMoveScriptButton);
    addButtonAction(addTerminationScriptButton);
    addButtonAction(runBuildScriptButton);
    addButtonAction(runAfterBuildScriptButton);
    addButtonAction(runMoveScriptButton);
    addButtonAction(runTerminationScriptButton);
    addButtonAction(saveTrainButton);
    if (_train != null) {
        trainName.setText(_train.getName());
        trainDescription.setText(_train.getDescription());
        enableButtons(true);
    } else {
        enableButtons(false);
    }
    // NOI18N
    addHelpMenu("package.jmri.jmrit.operations.Operations_TrainScripts", true);
    initMinimumSize();
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagLayout(java.awt.GridBagLayout) BoxLayout(javax.swing.BoxLayout)

Example 83 with BoxLayout

use of javax.swing.BoxLayout in project JMRI by JMRI.

the class SpeedProfilePanel method makePadPanel.

static JPanel makePadPanel(Component comp) {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    panel.add(Box.createRigidArea(new java.awt.Dimension(20, 20)));
    panel.add(comp);
    return panel;
}
Also used : JPanel(javax.swing.JPanel) BoxLayout(javax.swing.BoxLayout)

Example 84 with BoxLayout

use of javax.swing.BoxLayout in project JMRI by JMRI.

the class CombinedLocoSelListPane method layoutDecoderSelection.

/**
     * Create the panel used to select the decoder
     */
@Override
protected JPanel layoutDecoderSelection() {
    JPanel pane1a = new JPanel();
    pane1a.setLayout(new BoxLayout(pane1a, BoxLayout.X_AXIS));
    pane1a.add(new JLabel("Decoder installed: "));
    // create the list of manufacturers
    mMfgList = new JList<>();
    updateMfgListContents(null);
    mMfgList.clearSelection();
    mMfgList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    mMfgListener = new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!mMfgList.isSelectionEmpty()) {
                // manufacturer selected, update decoder list
                String vMfg = mMfgList.getSelectedValue();
                try {
                    int vMfgID = Integer.parseInt(DecoderIndexFile.instance().mfgIdFromName(vMfg));
                    listDecodersFromMfg(vMfgID, vMfg);
                } catch (java.lang.NumberFormatException ex) {
                // mfg number lookup failed for some reason
                }
            } else {
            // no manufacturer selected, do nothing
            }
        }
    };
    mMfgList.addListSelectionListener(mMfgListener);
    mDecoderList = new JList<String>(DecoderIndexFile.instance().matchingComboBox(null, null, null, null, null, null).getModel());
    mDecoderList.clearSelection();
    mDecoderList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    mDecoderListener = new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!mDecoderList.isSelectionEmpty()) {
                // decoder selected - reset and disable loco selection
                locoBox.setSelectedIndex(0);
                go2.setEnabled(true);
                go2.setToolTipText("Click to open the programmer");
                updateMfgListToSelectedDecoder();
            } else {
                // decoder not selected - require one
                go2.setEnabled(false);
                go2.setToolTipText("Select a locomotive or decoder to enable");
            }
        }
    };
    mDecoderList.addListSelectionListener(mDecoderListener);
    pane1a.add(new JScrollPane(mMfgList));
    pane1a.add(new JScrollPane(mDecoderList));
    iddecoder = new JToggleButton("Ident");
    iddecoder.setToolTipText("Read the decoders mfg and version, then attempt to select its type");
    if (jmri.InstanceManager.getNullableDefault(jmri.ProgrammerManager.class) != null && jmri.InstanceManager.getDefault(jmri.ProgrammerManager.class).getGlobalProgrammer() != null && !jmri.InstanceManager.getDefault(jmri.ProgrammerManager.class).getGlobalProgrammer().getCanRead()) {
        // can't read, disable the button
        iddecoder.setEnabled(false);
        iddecoder.setToolTipText("Button disabled because configured command station can't read CVs");
    }
    iddecoder.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            if (log.isDebugEnabled()) {
                log.debug("identify decoder pressed");
            }
            startIdentifyDecoder();
        }
    });
    pane1a.add(iddecoder);
    pane1a.setAlignmentX(JLabel.RIGHT_ALIGNMENT);
    return pane1a;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) BoxLayout(javax.swing.BoxLayout) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JLabel(javax.swing.JLabel) ListSelectionListener(javax.swing.event.ListSelectionListener) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener)

Example 85 with BoxLayout

use of javax.swing.BoxLayout in project JMRI by JMRI.

the class PaneEditAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (log.isDebugEnabled()) {
        log.debug("Pane programmer requested");
    }
    // create the initial frame that steers
    final JmriJFrame f = new JmriJFrame(SymbolicProgBundle.getMessage("FrameEditEntrySetup"));
    f.getContentPane().setLayout(new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS));
    // add the Roster menu
    JMenuBar menuBar = new JMenuBar();
    // menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));
    menuBar.add(new jmri.jmrit.roster.swing.RosterMenu(SymbolicProgBundle.getMessage("MenuRoster"), jmri.jmrit.roster.swing.RosterMenu.MAINMENU, f));
    f.setJMenuBar(menuBar);
    // known entry, no programmer
    JPanel pane1 = new // not programming
    KnownLocoSelPane(// not programming
    false) {

        @Override
        protected void startProgrammer(DecoderFile decoderFile, RosterEntry re, String filename) {
            String title = SymbolicProgBundle.getMessage("FrameEditEntryTitle");
            JFrame p = new PaneProgFrame(decoderFile, re, title, "programmers" + File.separator + filename + ".xml", null, false) {

                @Override
                protected JPanel getModePane() {
                    return null;
                }
            };
            p.pack();
            p.setVisible(true);
        }
    };
    // load primary frame
    pane1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
    f.getContentPane().add(pane1);
    f.pack();
    if (log.isDebugEnabled()) {
        log.debug("Tab-Programmer setup created");
    }
    f.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) DecoderFile(jmri.jmrit.decoderdefn.DecoderFile) BoxLayout(javax.swing.BoxLayout) KnownLocoSelPane(jmri.jmrit.symbolicprog.KnownLocoSelPane) JmriJFrame(jmri.util.JmriJFrame) JmriJFrame(jmri.util.JmriJFrame) JFrame(javax.swing.JFrame) RosterEntry(jmri.jmrit.roster.RosterEntry) JMenuBar(javax.swing.JMenuBar)

Aggregations

BoxLayout (javax.swing.BoxLayout)593 JPanel (javax.swing.JPanel)510 JLabel (javax.swing.JLabel)301 Dimension (java.awt.Dimension)189 ActionEvent (java.awt.event.ActionEvent)179 JButton (javax.swing.JButton)173 ActionListener (java.awt.event.ActionListener)155 JScrollPane (javax.swing.JScrollPane)140 FlowLayout (java.awt.FlowLayout)130 JCheckBox (javax.swing.JCheckBox)74 BorderLayout (java.awt.BorderLayout)73 GridBagLayout (java.awt.GridBagLayout)66 ButtonGroup (javax.swing.ButtonGroup)58 JTable (javax.swing.JTable)53 JTextField (javax.swing.JTextField)53 Container (java.awt.Container)51 JmriJFrame (jmri.util.JmriJFrame)45 JComboBox (javax.swing.JComboBox)44 JSeparator (javax.swing.JSeparator)44 Box (javax.swing.Box)41