Search in sources :

Example 96 with JSeparator

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

the class PreviewDialog method init.

protected void init(ActionListener moreAction, ActionListener lookAction, ActionListener cancelAction, int startNum) {
    if (log.isDebugEnabled()) {
        log.debug("Enter _previewDialog.init dir= {}", _currentDir.getPath());
    }
    addWindowListener(new java.awt.event.WindowAdapter() {

        @Override
        public void windowClosing(java.awt.event.WindowEvent e) {
            DirectorySearcher.instance().close();
            dispose();
        }
    });
    JPanel pTop = new JPanel();
    pTop.setLayout(new BoxLayout(pTop, BoxLayout.Y_AXIS));
    pTop.add(new JLabel(_currentDir.getPath()));
    JTextField msg = new JTextField();
    msg.setFont(new Font("Dialog", Font.BOLD, 12));
    msg.setEditable(false);
    msg.setBackground(pTop.getBackground());
    pTop.add(msg);
    getContentPane().add(pTop, BorderLayout.NORTH);
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
    p.add(Box.createHorizontalStrut(5));
    // provide panel for images, add to bottom of window
    JPanel previewPanel = setupPanel();
    _startNum = startNum;
    needsMore = setIcons(startNum);
    if (_noMemory) {
        int choice = JOptionPane.showOptionDialog(null, Bundle.getMessage("OutOfMemory", _cnt), Bundle.getMessage("ErrorTitle"), JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, new String[] { Bundle.getMessage("Quit"), Bundle.getMessage("ShowContents") }, 1);
        if (choice == 0) {
            return;
        }
    }
    if (needsMore) {
        if (moreAction != null) {
            p.add(Box.createHorizontalStrut(5));
            JButton moreButton = new JButton(Bundle.getMessage("ButtonDisplayMore"));
            moreButton.addActionListener(moreAction);
            moreButton.setVisible(needsMore);
            p.add(moreButton);
        } else {
            log.error("More ActionListener missing");
        }
        msg.setText(Bundle.getMessage("moreMsg"));
    }
    boolean hasButtons = needsMore;
    msg.setText(Bundle.getMessage("dragMsg"));
    _lookAction = lookAction;
    if (lookAction != null) {
        p.add(Box.createHorizontalStrut(5));
        JButton lookButton = new JButton(Bundle.getMessage("ButtonKeepLooking"));
        lookButton.addActionListener(lookAction);
        p.add(lookButton);
        hasButtons = true;
    }
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    if (hasButtons) {
        p.add(Box.createHorizontalStrut(5));
        JButton cancelButton = new JButton(Bundle.getMessage("ButtonCancel"));
        cancelButton.addActionListener(cancelAction);
        p.add(cancelButton);
        p.add(Box.createHorizontalStrut(5));
        p.setPreferredSize(new Dimension(400, cancelButton.getPreferredSize().height));
        panel.add(p);
        panel.add(new JSeparator());
    }
    panel.add(previewPanel);
    getContentPane().add(panel);
    setLocationRelativeTo(null);
    pack();
    setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) Font(java.awt.Font) JSeparator(javax.swing.JSeparator)

Example 97 with JSeparator

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

the class AutoTrainsFrame method displayAutoTrains.

protected void displayAutoTrains() {
    // set up AutoTrains to display
    while (_autoTrainsList.size() > _JPanels.size()) {
        newTrainLine();
    }
    for (int i = 0; i < _autoTrainsList.size(); i++) {
        AutoActiveTrain aat = _autoTrainsList.get(i);
        if (aat != null) {
            if (i > 0) {
                JSeparator sep = _separators.get(i);
                sep.setVisible(true);
            }
            JPanel panel = _JPanels.get(i);
            panel.setVisible(true);
            ActiveTrain at = aat.getActiveTrain();
            JLabel tName = _trainLabels.get(i);
            tName.setText(at.getTrainName());
            JButton stopButton = _stopButtons.get(i);
            if (at.getStatus() == ActiveTrain.STOPPED) {
                stopButton.setText(Bundle.getMessage("ResumeButton"));
                stopButton.setToolTipText(Bundle.getMessage("ResumeButtonHint"));
                _resumeAutoRunningButtons.get(i).setVisible(false);
            } else if (at.getStatus() == ActiveTrain.DONE) {
                stopButton.setText(Bundle.getMessage("RestartButton"));
                stopButton.setToolTipText(Bundle.getMessage("RestartButtonHint"));
                _resumeAutoRunningButtons.get(i).setVisible(false);
            } else if (at.getStatus() == ActiveTrain.WORKING) {
                stopButton.setVisible(false);
            } else {
                stopButton.setText(Bundle.getMessage("StopButton"));
                stopButton.setToolTipText(Bundle.getMessage("StopButtonHint"));
                stopButton.setVisible(true);
            }
            JButton manualButton = _manualButtons.get(i);
            if (at.getMode() == ActiveTrain.AUTOMATIC) {
                manualButton.setText(Bundle.getMessage("ToManualButton"));
                manualButton.setToolTipText(Bundle.getMessage("ToManualButtonHint"));
                manualButton.setVisible(true);
                _resumeAutoRunningButtons.get(i).setVisible(false);
                _forwardButtons.get(i).setVisible(false);
                _reverseButtons.get(i).setVisible(false);
                _speedSliders.get(i).setVisible(false);
                _throttleStatus.get(i).setVisible(true);
            } else if ((at.getMode() == ActiveTrain.MANUAL) && ((at.getStatus() == ActiveTrain.WORKING) || (at.getStatus() == ActiveTrain.READY))) {
                manualButton.setVisible(false);
                _resumeAutoRunningButtons.get(i).setVisible(true);
                _forwardButtons.get(i).setVisible(false);
                _reverseButtons.get(i).setVisible(false);
                _speedSliders.get(i).setVisible(true);
                _throttleStatus.get(i).setVisible(true);
            } else {
                manualButton.setText(Bundle.getMessage("ToAutoButton"));
                manualButton.setToolTipText(Bundle.getMessage("ToAutoButtonHint"));
                _forwardButtons.get(i).setVisible(true);
                _reverseButtons.get(i).setVisible(true);
                _speedSliders.get(i).setVisible(true);
                _throttleStatus.get(i).setVisible(false);
                _forwardButtons.get(i).setSelected(aat.getForward());
                _reverseButtons.get(i).setSelected(!aat.getForward());
                int speedValue = (int) (aat.getTargetSpeed() * 100.0f);
                _speedSliders.get(i).setValue(speedValue);
            }
        }
    }
    // clear unused item rows, if needed
    for (int j = _autoTrainsList.size(); j < _JPanels.size(); j++) {
        JPanel panel = _JPanels.get(j);
        panel.setVisible(false);
        JSeparator sep = _separators.get(j);
        sep.setVisible(false);
    }
    autoTrainsFrame.pack();
    autoTrainsFrame.setAutoRequestFocus(false);
    autoTrainsFrame.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Point(java.awt.Point) JSeparator(javax.swing.JSeparator)

Example 98 with JSeparator

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

the class AutoTrainsFrame method newSeparator.

private void newSeparator() {
    JSeparator sep = new JSeparator();
    _separators.add(sep);
    contentPane.add(sep);
}
Also used : JSeparator(javax.swing.JSeparator)

Example 99 with JSeparator

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

the class AutoTrainsFrame method initializeAutoTrainsWindow.

private void initializeAutoTrainsWindow() {
    autoTrainsFrame = this;
    autoTrainsFrame.setTitle(Bundle.getMessage("TitleAutoTrains"));
    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    autoTrainsFrame.addHelpMenu("package.jmri.jmrit.dispatcher.AutoTrains", true);
    contentPane = autoTrainsFrame.getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    // set up 6 auto trains to size the panel
    for (int i = 0; i < 6; i++) {
        newTrainLine();
        if (i == 0) {
            _separators.get(i).setVisible(false);
        }
    }
    contentPane.add(new JSeparator());
    contentPane.add(new JSeparator());
    JPanel pB = new JPanel();
    pB.setLayout(new FlowLayout());
    JButton stopAllButton = new JButton(Bundle.getMessage("StopAll"));
    pB.add(stopAllButton);
    stopAllButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            stopAllPressed(e);
        }
    });
    stopAllButton.setToolTipText(Bundle.getMessage("StopAllButtonHint"));
    contentPane.add(pB);
    autoTrainsFrame.pack();
    placeWindow();
    displayAutoTrains();
    autoTrainsFrame.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JMenuBar(javax.swing.JMenuBar) Point(java.awt.Point) JSeparator(javax.swing.JSeparator)

Example 100 with JSeparator

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

the class IconAdder method complete.

/*
     * Supports selection of NamedBean from a pick list table
     * @param addIconAction - ActionListener that adds an icon to the panel -
     * representing either an entity a pick list selection, an
     * arbitrary inmage, or a value, such a
     * memory value.
     * @param changeIconAction - ActionListener that displays sources from
     * which to select an image file.  
     */
public void complete(ActionListener addIconAction, boolean changeIcon, boolean addToTable, boolean update) {
    _update = update;
    if (_buttonPanel != null) {
        this.remove(_buttonPanel);
    }
    _buttonPanel = new JPanel();
    _buttonPanel.setLayout(new BoxLayout(_buttonPanel, BoxLayout.Y_AXIS));
    JPanel p = new JPanel();
    p.setLayout(new FlowLayout());
    if (addToTable) {
        _sysNametext = new JTextField();
        _sysNametext.setPreferredSize(new Dimension(150, _sysNametext.getPreferredSize().height + 2));
        _addTableButton = new JButton(Bundle.getMessage("addToTable"));
        _addTableButton.addActionListener((ActionEvent a) -> {
            addToTable();
        });
        _addTableButton.setEnabled(false);
        _addTableButton.setToolTipText(Bundle.getMessage("ToolTipWillActivate"));
        p.add(_sysNametext);
        _sysNametext.addKeyListener(new KeyAdapter() {

            @Override
            public void keyReleased(KeyEvent a) {
                if (_sysNametext.getText().length() > 0) {
                    _addTableButton.setEnabled(true);
                    _addTableButton.setToolTipText(null);
                    _table.clearSelection();
                }
            }
        });
        p.add(_addTableButton);
        _buttonPanel.add(p);
        p = new JPanel();
        //new BoxLayout(p, BoxLayout.Y_AXIS)
        p.setLayout(new FlowLayout());
    }
    if (update) {
        _addButton = new JButton(Bundle.getMessage("ButtonUpdateIcon"));
    } else {
        _addButton = new JButton(Bundle.getMessage("ButtonAddIcon"));
    }
    _addButton.addActionListener(addIconAction);
    _addButton.setEnabled(true);
    if (changeIcon) {
        _changeButton = new JButton(Bundle.getMessage("ButtonChangeIcon"));
        _changeButton.addActionListener((ActionEvent a) -> {
            addCatalog();
        });
        p.add(_changeButton);
        _closeButton = new JButton(Bundle.getMessage("ButtonCloseCatalog"));
        _closeButton.addActionListener((ActionEvent a) -> {
            closeCatalog();
        });
        _closeButton.setVisible(false);
        p.add(_closeButton);
    }
    _buttonPanel.add(p);
    if (_table != null) {
        _addButton.setEnabled(false);
        _addButton.setToolTipText(Bundle.getMessage("ToolTipPickFromTable"));
    }
    addAdditionalButtons(_buttonPanel);
    p = new JPanel();
    p.add(_addButton);
    _buttonPanel.add(p);
    _buttonPanel.add(Box.createVerticalStrut(STRUT_SIZE));
    _buttonPanel.add(new JSeparator());
    this.add(_buttonPanel);
    if (changeIcon) {
        _catalog = CatalogPanel.makeDefaultCatalog();
        _catalog.setVisible(false);
        _catalog.setToolTipText(Bundle.getMessage("ToolTipDragIcon"));
        this.add(_catalog);
    }
    if (_type != null) /*&& _defaultIcons == null*/
    {
        getDefaultIconNodeFromMap();
    }
    // Allow initial row to be set without getting callback to valueChanged
    if (_table != null) {
        _table.getSelectionModel().addListSelectionListener(this);
    }
    pack();
}
Also used : KeyEvent(java.awt.event.KeyEvent) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) KeyAdapter(java.awt.event.KeyAdapter) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator)

Aggregations

JSeparator (javax.swing.JSeparator)147 JPanel (javax.swing.JPanel)74 JLabel (javax.swing.JLabel)65 ActionEvent (java.awt.event.ActionEvent)44 BoxLayout (javax.swing.BoxLayout)44 JButton (javax.swing.JButton)44 JMenuItem (javax.swing.JMenuItem)38 JMenu (javax.swing.JMenu)32 GridBagConstraints (java.awt.GridBagConstraints)31 Insets (java.awt.Insets)30 ActionListener (java.awt.event.ActionListener)30 Dimension (java.awt.Dimension)24 FlowLayout (java.awt.FlowLayout)24 JScrollPane (javax.swing.JScrollPane)24 GridBagLayout (java.awt.GridBagLayout)22 JPopupMenu (javax.swing.JPopupMenu)19 BorderLayout (java.awt.BorderLayout)16 JTextField (javax.swing.JTextField)16 JCheckBox (javax.swing.JCheckBox)13 AbstractAction (javax.swing.AbstractAction)12