Search in sources :

Example 61 with ButtonGroup

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

the class PreviewDialog method setupPanel.

/**
     * Setup a display panel to display icons
     */
private JPanel setupPanel() {
    JPanel previewPanel = new JPanel();
    previewPanel.setLayout(new BoxLayout(previewPanel, BoxLayout.Y_AXIS));
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
    p.add(_previewLabel);
    previewPanel.add(p);
    _preview = new JPanel();
    JScrollPane js = new JScrollPane(_preview);
    previewPanel.add(js);
    JRadioButton whiteButton = new JRadioButton(Bundle.getMessage("white"), false);
    JRadioButton grayButton = new JRadioButton(Bundle.getMessage("lightGray"), true);
    JRadioButton darkButton = new JRadioButton(Bundle.getMessage("darkGray"), false);
    whiteButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setBackGround(Color.white);
        }
    });
    grayButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setBackGround(_grayColor);
        }
    });
    darkButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setBackGround(new Color(150, 150, 150));
        }
    });
    JPanel pp = new JPanel();
    pp.add(new JLabel(Bundle.getMessage("setBackground")));
    previewPanel.add(pp);
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
    ButtonGroup selGroup = new ButtonGroup();
    selGroup.add(whiteButton);
    selGroup.add(grayButton);
    selGroup.add(darkButton);
    panel.add(whiteButton);
    panel.add(grayButton);
    panel.add(darkButton);
    previewPanel.add(panel);
    return previewPanel;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) JRadioButton(javax.swing.JRadioButton) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) Color(java.awt.Color) JLabel(javax.swing.JLabel)

Example 62 with ButtonGroup

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

the class AutoTrainsFrame method newTrainLine.

private void newTrainLine() {
    int i = _JPanels.size();
    final String s = "" + i;
    newSeparator();
    JPanel px = new JPanel();
    px.setLayout(new FlowLayout());
    _JPanels.add(px);
    JLabel tLabel = new JLabel("      ");
    px.add(tLabel);
    px.add(tLabel);
    _trainLabels.add(tLabel);
    JButton tStop = new JButton(Bundle.getMessage("ResumeButton"));
    px.add(tStop);
    _stopButtons.add(tStop);
    tStop.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            stopResume(s);
        }
    });
    JButton tManual = new JButton(Bundle.getMessage("ToManualButton"));
    px.add(tManual);
    _manualButtons.add(tManual);
    tManual.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            manualAuto(s);
        }
    });
    JButton tResumeAuto = new JButton(Bundle.getMessage("ResumeAutoButton"));
    px.add(tResumeAuto);
    _resumeAutoRunningButtons.add(tResumeAuto);
    tResumeAuto.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            resumeAutoOperation(s);
        }
    });
    tResumeAuto.setVisible(false);
    tResumeAuto.setToolTipText(Bundle.getMessage("ResumeAutoButtonHint"));
    ButtonGroup directionGroup = new ButtonGroup();
    JRadioButton fBut = new JRadioButton(Bundle.getMessage("ForwardRadio"));
    px.add(fBut);
    _forwardButtons.add(fBut);
    fBut.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            directionButton(s);
        }
    });
    directionGroup.add(fBut);
    JRadioButton rBut = new JRadioButton(Bundle.getMessage("ReverseRadio"));
    px.add(rBut);
    _reverseButtons.add(rBut);
    rBut.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            directionButton(s);
        }
    });
    directionGroup.add(rBut);
    JSlider sSlider = new JSlider(0, 100, 0);
    px.add(sSlider);
    _speedSliders.add(sSlider);
    sSlider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            int val = ((JSlider) (e.getSource())).getValue();
            sliderChanged(s, val);
        }
    });
    JLabel _throttle = new JLabel();
    _throttle.setText("Speed Unknown");
    _throttleStatus.add(_throttle);
    px.add(_throttle);
    contentPane.add(px);
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) JRadioButton(javax.swing.JRadioButton) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Point(java.awt.Point) ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) ButtonGroup(javax.swing.ButtonGroup) JSlider(javax.swing.JSlider) ChangeListener(javax.swing.event.ChangeListener)

Example 63 with ButtonGroup

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

the class OptionsMenu method optionWindowRequested.

private void optionWindowRequested(ActionEvent e) {
    if (optionsFrame == null) {
        optionsFrame = new JmriJFrame(Bundle.getMessage("MenuOptions"), false, true);
        optionsFrame.addHelpMenu("package.jmri.jmrit.dispatcher.Options", true);
        optionsPane = optionsFrame.getContentPane();
        optionsPane.setLayout(new BoxLayout(optionsFrame.getContentPane(), BoxLayout.Y_AXIS));
        JPanel p1 = new JPanel();
        p1.setLayout(new FlowLayout());
        p1.add(useConnectivityCheckBox);
        useConnectivityCheckBox.setToolTipText(Bundle.getMessage("UseConnectivityHint"));
        p1.add(layoutEditorBox);
        layoutEditorBox.setToolTipText(Bundle.getMessage("LayoutEditorHint"));
        signalTypeBox = new JComboBox<String>(signalTypes);
        p1.add(signalTypeBox);
        signalTypeBox.setToolTipText(Bundle.getMessage("SignalTypeHint"));
        optionsPane.add(p1);
        JPanel p2 = new JPanel();
        p2.setLayout(new FlowLayout());
        ButtonGroup trainsGroup = new ButtonGroup();
        p2.add(trainsFromRoster);
        trainsFromRoster.setToolTipText(Bundle.getMessage("TrainsFromRosterHint"));
        trainsGroup.add(trainsFromRoster);
        ActionListener useRosterEntryListener = new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (trainsFromRoster.isSelected()) {
                    rosterInBlockCheckBox.setEnabled(true);
                    if (nameInBlockCheckBox.isSelected() && e.getSource() == nameInBlockCheckBox) {
                        rosterInBlockCheckBox.setSelected(false);
                    } else if (rosterInBlockCheckBox.isSelected() && e.getSource() == rosterInBlockCheckBox) {
                        nameInBlockCheckBox.setSelected(false);
                    }
                } else {
                    rosterInBlockCheckBox.setEnabled(false);
                }
            }
        };
        trainsFromRoster.addActionListener(useRosterEntryListener);
        p2.add(new JLabel("     "));
        p2.add(trainsFromTrains);
        trainsFromTrains.setToolTipText(Bundle.getMessage("TrainsFromTrainsHint"));
        trainsFromTrains.addActionListener(useRosterEntryListener);
        trainsGroup.add(trainsFromTrains);
        p2.add(new JLabel("     "));
        p2.add(trainsFromUser);
        trainsFromUser.setToolTipText(Bundle.getMessage("TrainsFromUserHint"));
        trainsFromUser.addActionListener(useRosterEntryListener);
        trainsGroup.add(trainsFromUser);
        optionsPane.add(p2);
        JPanel p3 = new JPanel();
        p3.setLayout(new FlowLayout());
        p3.add(detectionCheckBox);
        detectionCheckBox.setToolTipText(Bundle.getMessage("DetectionBoxHint"));
        optionsPane.add(p3);
        JPanel p4 = new JPanel();
        p4.setLayout(new FlowLayout());
        p4.add(autoAllocateCheckBox);
        autoAllocateCheckBox.setToolTipText(Bundle.getMessage("AutoAllocateBoxHint"));
        optionsPane.add(p4);
        JPanel p5 = new JPanel();
        p5.setLayout(new FlowLayout());
        p5.add(autoTurnoutsCheckBox);
        autoTurnoutsCheckBox.setToolTipText(Bundle.getMessage("AutoTurnoutsBoxHint"));
        optionsPane.add(p5);
        JPanel p16 = new JPanel();
        p16.setLayout(new FlowLayout());
        p16.add(trustKnownTurnoutsCheckBox);
        trustKnownTurnoutsCheckBox.setToolTipText(Bundle.getMessage("trustKnownTurnoutsHint"));
        optionsPane.add(p16);
        JPanel p6 = new JPanel();
        p6.setLayout(new FlowLayout());
        p6.add(shortNameCheckBox);
        shortNameCheckBox.setToolTipText(Bundle.getMessage("ShortNameBoxHint"));
        optionsPane.add(p6);
        JPanel p7 = new JPanel();
        p7.setLayout(new FlowLayout());
        p7.add(nameInBlockCheckBox);
        nameInBlockCheckBox.setToolTipText(Bundle.getMessage("NameInBlockBoxHint"));
        nameInBlockCheckBox.addActionListener(useRosterEntryListener);
        optionsPane.add(p7);
        JPanel p7b = new JPanel();
        p7b.setLayout(new FlowLayout());
        p7b.add(rosterInBlockCheckBox);
        rosterInBlockCheckBox.setToolTipText(Bundle.getMessage("RosterInBlockBoxHint"));
        rosterInBlockCheckBox.addActionListener(useRosterEntryListener);
        optionsPane.add(p7b);
        JPanel p10 = new JPanel();
        p10.setLayout(new FlowLayout());
        p10.add(extraColorForAllocatedCheckBox);
        extraColorForAllocatedCheckBox.setToolTipText(Bundle.getMessage("ExtraColorForAllocatedBoxHint"));
        optionsPane.add(p10);
        JPanel p11 = new JPanel();
        p11.setLayout(new FlowLayout());
        p11.add(nameInAllocatedBlockCheckBox);
        nameInAllocatedBlockCheckBox.setToolTipText(Bundle.getMessage("NameInAllocatedBlockBoxHint"));
        optionsPane.add(p11);
        JPanel p13 = new JPanel();
        p13.setLayout(new FlowLayout());
        p13.add(supportVSDecoderCheckBox);
        supportVSDecoderCheckBox.setToolTipText(Bundle.getMessage("SupportVSDecoderBoxHint"));
        optionsPane.add(p13);
        JPanel p8 = new JPanel();
        initializeScaleCombo();
        p8.add(new JLabel(Bundle.getMessage("LayoutScale") + ":"));
        p8.add(layoutScaleBox);
        layoutScaleBox.setToolTipText(Bundle.getMessage("ScaleBoxHint"));
        optionsPane.add(p8);
        JPanel p12 = new JPanel();
        p12.setLayout(new FlowLayout());
        p12.add(new JLabel(Bundle.getMessage("Units") + "  "));
        ButtonGroup scaleGroup = new ButtonGroup();
        p12.add(scaleFeet);
        scaleFeet.setToolTipText(Bundle.getMessage("ScaleFeetHint"));
        scaleGroup.add(scaleFeet);
        p12.add(new JLabel("  "));
        p12.add(scaleMeters);
        scaleMeters.setToolTipText(Bundle.getMessage("ScaleMetersHint"));
        scaleGroup.add(scaleMeters);
        optionsPane.add(p12);
        JPanel p15 = new JPanel();
        p15.setLayout(new FlowLayout());
        p15.add(new JLabel(Bundle.getMessage("minThrottleInterval") + " :"));
        NumberFormatter numberFormatter = new NumberFormatter(NumberFormat.getIntegerInstance());
        numberFormatter.setValueClass(Integer.class);
        numberFormatter.setMinimum(20);
        numberFormatter.setMaximum(1000);
        minThrottleIntervalTextField = new JFormattedTextField(numberFormatter);
        minThrottleIntervalTextField.setColumns(4);
        minThrottleIntervalTextField.setValue(250);
        minThrottleIntervalTextField.setToolTipText(Bundle.getMessage("minThrottleIntervalHint"));
        p15.add(minThrottleIntervalTextField);
        p15.add(new JLabel(Bundle.getMessage("ms")));
        optionsPane.add(p15);
        JPanel p17 = new JPanel();
        p17.setLayout(new FlowLayout());
        p17.add(new JLabel(Bundle.getMessage("fullRampTime") + " :"));
        numberFormatter = new NumberFormatter(NumberFormat.getIntegerInstance());
        numberFormatter.setValueClass(Integer.class);
        numberFormatter.setMinimum(1000);
        numberFormatter.setMaximum(20000);
        fullRampTimeTextField = new JFormattedTextField(numberFormatter);
        fullRampTimeTextField.setColumns(4);
        fullRampTimeTextField.setValue(5000);
        fullRampTimeTextField.setToolTipText(Bundle.getMessage("fullRampTimeHint"));
        p17.add(fullRampTimeTextField);
        p17.add(new JLabel(Bundle.getMessage("ms")));
        optionsPane.add(p17);
        JPanel p14 = new JPanel();
        p14.setLayout(new FlowLayout());
        p14.add(openDispatcherWithPanel);
        openDispatcherWithPanel.setToolTipText(Bundle.getMessage("OpenDispatcherWithPanelBoxHint"));
        optionsPane.add(p14);
        optionsPane.add(new JSeparator());
        JPanel p9 = new JPanel();
        p9.setLayout(new FlowLayout());
        JButton cancelButton = null;
        p9.add(cancelButton = new JButton(Bundle.getMessage("ButtonCancel")));
        cancelButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                cancelOptions(e);
            }
        });
        cancelButton.setToolTipText(Bundle.getMessage("CancelButtonHint2"));
        p9.add(new JLabel("     "));
        JButton applyButton = null;
        p9.add(applyButton = new JButton(Bundle.getMessage("ButtonApply")));
        applyButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                applyOptions(e);
            }
        });
        applyButton.setToolTipText(Bundle.getMessage("ApplyButtonHint"));
        optionsPane.add(p9);
    }
    if (initializeLayoutEditorCombo()) {
        useConnectivityCheckBox.setVisible(true);
        layoutEditorBox.setVisible(true);
    } else {
        useConnectivityCheckBox.setVisible(false);
        layoutEditorBox.setVisible(false);
    }
    useConnectivityCheckBox.setSelected(dispatcher.getUseConnectivity());
    signalTypeBox.setSelectedIndex(dispatcher.getSignalType());
    trainsFromRoster.setSelected(dispatcher.getTrainsFromRoster());
    trainsFromTrains.setSelected(dispatcher.getTrainsFromTrains());
    trainsFromUser.setSelected(dispatcher.getTrainsFromUser());
    detectionCheckBox.setSelected(dispatcher.getHasOccupancyDetection());
    autoAllocateCheckBox.setSelected(dispatcher.getAutoAllocate());
    autoTurnoutsCheckBox.setSelected(dispatcher.getAutoTurnouts());
    trustKnownTurnoutsCheckBox.setSelected(dispatcher.getTrustKnownTurnouts());
    shortNameCheckBox.setSelected(dispatcher.getShortActiveTrainNames());
    nameInBlockCheckBox.setSelected(dispatcher.getShortNameInBlock());
    rosterInBlockCheckBox.setSelected(dispatcher.getRosterEntryInBlock());
    extraColorForAllocatedCheckBox.setSelected(dispatcher.getExtraColorForAllocated());
    nameInAllocatedBlockCheckBox.setSelected(dispatcher.getNameInAllocatedBlock());
    supportVSDecoderCheckBox.setSelected(dispatcher.getSupportVSDecoder());
    scaleMeters.setSelected(dispatcher.getUseScaleMeters());
    scaleFeet.setSelected(!dispatcher.getUseScaleMeters());
    minThrottleIntervalTextField.setValue(dispatcher.getMinThrottleInterval());
    fullRampTimeTextField.setValue(dispatcher.getFullRampTime());
    if (dispatcher.getLayoutEditor() != null) {
        openDispatcherWithPanel.setSelected(dispatcher.getLayoutEditor().getOpenDispatcherOnLoad());
    }
    optionsFrame.pack();
    optionsFrame.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JFormattedTextField(javax.swing.JFormattedTextField) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) JSeparator(javax.swing.JSeparator) ActionListener(java.awt.event.ActionListener) JmriJFrame(jmri.util.JmriJFrame) ButtonGroup(javax.swing.ButtonGroup) NumberFormatter(javax.swing.text.NumberFormatter)

Example 64 with ButtonGroup

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

the class PositionablePopupUtil method makeFontSizeMenu.

protected JMenu makeFontSizeMenu() {
    JMenu sizeMenu = new JMenu("Font Size");
    ButtonGroup buttonGrp = new ButtonGroup();
    addFontMenuEntry(sizeMenu, buttonGrp, 6);
    addFontMenuEntry(sizeMenu, buttonGrp, 8);
    addFontMenuEntry(sizeMenu, buttonGrp, 10);
    addFontMenuEntry(sizeMenu, buttonGrp, 11);
    addFontMenuEntry(sizeMenu, buttonGrp, 12);
    addFontMenuEntry(sizeMenu, buttonGrp, 14);
    addFontMenuEntry(sizeMenu, buttonGrp, 16);
    addFontMenuEntry(sizeMenu, buttonGrp, 20);
    addFontMenuEntry(sizeMenu, buttonGrp, 24);
    addFontMenuEntry(sizeMenu, buttonGrp, 28);
    addFontMenuEntry(sizeMenu, buttonGrp, 32);
    addFontMenuEntry(sizeMenu, buttonGrp, 36);
    return sizeMenu;
}
Also used : ButtonGroup(javax.swing.ButtonGroup) JMenu(javax.swing.JMenu)

Example 65 with ButtonGroup

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

the class SlipIconAdder method makeIconPanel.

/**
     * Override. First look for a table selection to set the sensor. If not,
     * then look to change the icon image (super).
     */
@Override
public void makeIconPanel(boolean useDefaults) {
    if (_iconPanel != null) {
        this.remove(_iconPanel);
    }
    //super.makeIconPanel();
    Dimension dim = null;
    _iconPanel = new JPanel();
    _iconPanel.setLayout(new BoxLayout(_iconPanel, BoxLayout.Y_AXIS));
    ButtonGroup typeGroup = new ButtonGroup();
    typeGroup.add(doubleSlipButton);
    typeGroup.add(singleSlipButton);
    typeGroup.add(threeWayButton);
    typeGroup.add(scissorButton);
    JPanel _typePanel = new JPanel();
    _typePanel.add(doubleSlipButton);
    _typePanel.add(singleSlipButton);
    _typePanel.add(threeWayButton);
    _typePanel.add(scissorButton);
    _iconPanel.add(_typePanel);
    doubleSlipButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            slipUpdate(0x00);
        }
    });
    singleSlipButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            slipUpdate(0x02);
        }
    });
    threeWayButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            slipUpdate(0x04);
        }
    });
    scissorButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            slipUpdate(0x08);
        }
    });
    if (lowerWestToLowerEastButton.getActionListeners().length > 0) {
        lowerWestToLowerEastButton.removeActionListener(lowerWestToLowerEastButton.getActionListeners()[0]);
    }
    if (upperWestToUpperEastButton.getActionListeners().length > 0) {
        upperWestToUpperEastButton.removeActionListener(upperWestToUpperEastButton.getActionListeners()[0]);
    }
    if (getTurnoutType() == 0x02) {
        ButtonGroup group = new ButtonGroup();
        group.add(lowerWestToLowerEastButton);
        group.add(upperWestToUpperEastButton);
        lowerWestToLowerEastButton.setText(Bundle.getMessage("LowerWestToLowerEast"));
        upperWestToUpperEastButton.setText(Bundle.getMessage("UpperWestToUpperEast"));
        JPanel _buttonSlipPanel = new JPanel();
        _buttonSlipPanel.add(lowerWestToLowerEastButton);
        _buttonSlipPanel.add(upperWestToUpperEastButton);
        _iconPanel.add(_buttonSlipPanel);
        lowerWestToLowerEastButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                updateSingleSlipRoute(false);
            }
        });
        upperWestToUpperEastButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                updateSingleSlipRoute(true);
            }
        });
    } else if (getTurnoutType() == 0x04) {
        ButtonGroup group = new ButtonGroup();
        lowerWestToLowerEastButton.setText(Bundle.getMessage("ToLower"));
        upperWestToUpperEastButton.setText(Bundle.getMessage("ToUpper"));
        group.add(lowerWestToLowerEastButton);
        group.add(upperWestToUpperEastButton);
        JPanel _buttonSlipPanel = new JPanel();
        _buttonSlipPanel.add(lowerWestToLowerEastButton);
        _buttonSlipPanel.add(upperWestToUpperEastButton);
        _iconPanel.add(_buttonSlipPanel);
    } else if (getTurnoutType() == 0x08) {
        ButtonGroup group = new ButtonGroup();
        lowerWestToLowerEastButton.setText("4 Turnouts");
        upperWestToUpperEastButton.setText("2 Turnouts");
        group.add(lowerWestToLowerEastButton);
        group.add(upperWestToUpperEastButton);
        JPanel _buttonSlipPanel = new JPanel();
        _buttonSlipPanel.add(lowerWestToLowerEastButton);
        _buttonSlipPanel.add(upperWestToUpperEastButton);
        _iconPanel.add(_buttonSlipPanel);
        lowerWestToLowerEastButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                changeNumScissorTurnouts();
            }
        });
        upperWestToUpperEastButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                changeNumScissorTurnouts();
            }
        });
    }
    JPanel rowPanel = null;
    int cnt = 0;
    int numTurnoutPanels = 2;
    if ((doubleSlip == 0x08) && (lowerWestToLowerEastButton.isSelected())) {
        numTurnoutPanels = 4;
    }
    for (int i = 0; i < numTurnoutPanels; i++) {
        if (rowPanel == null) {
            rowPanel = new JPanel();
            rowPanel.setLayout(new BoxLayout(rowPanel, BoxLayout.X_AXIS));
            rowPanel.add(Box.createHorizontalStrut(STRUT_SIZE));
        }
        JPanel p3 = new DropPanel();
        p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS));
        JPanel p4 = new JPanel();
        String label;
        String key;
        NamedBeanHandle<Turnout> turnout;
        if (i == 0) {
            if (doubleSlip == 0x04) {
                label = Bundle.getMessage("FirstTurnout");
            } else if (doubleSlip == 0x08) {
                if (lowerWestToLowerEastButton.isSelected()) {
                    label = Bundle.getMessage("UpperWestTurnout");
                } else {
                    label = Bundle.getMessage("RHCrossing");
                }
            } else {
                label = Bundle.getMessage("WestTurnout");
            }
            key = "west";
        } else if (i == 1) {
            key = "east";
            if (doubleSlip == 0x04) {
                label = Bundle.getMessage("SecondTurnout");
            } else if (doubleSlip == 0x08) {
                if (lowerWestToLowerEastButton.isSelected()) {
                    label = Bundle.getMessage("UpperEastTurnout");
                } else {
                    label = Bundle.getMessage("LHCrossing");
                }
            } else {
                label = Bundle.getMessage("EastTurnout");
            }
        } else if (i == 2) {
            key = "lowerwest";
            label = Bundle.getMessage("LowerWestTurnout");
        } else {
            key = "lowereast";
            label = Bundle.getMessage("LowerEastTurnout");
        }
        turnout = _turnoutMap.get(key);
        JLabel k = new JLabel(key);
        k.setName(key);
        k.setVisible(false);
        p3.add(k);
        p4.add(new JLabel(label));
        p3.add(p4);
        p4 = new JPanel();
        String name = Bundle.getMessage("notSet");
        java.awt.Color color = java.awt.Color.RED;
        if (turnout != null) {
            name = turnout.getName();
            color = java.awt.Color.BLACK;
        }
        p4.setBorder(BorderFactory.createLineBorder(color));
        p4.add(new JLabel(name));
        p4.setMaximumSize(p4.getPreferredSize());
        p3.add(p4);
        JPanel p13 = new JPanel();
        p13.setLayout(new BoxLayout(p13, BoxLayout.X_AXIS));
        p13.add(p3);
        JPanel panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
        panel.add(p13);
        panel.setBorder(BorderFactory.createLineBorder(java.awt.Color.BLACK));
        rowPanel.add(panel);
        rowPanel.add(Box.createHorizontalStrut(STRUT_SIZE));
        cnt++;
        if ((cnt % 2) == 0) {
            _iconPanel.add(rowPanel);
            rowPanel = null;
        }
        dim = panel.getPreferredSize();
    }
    while ((cnt % 2) != 0) {
        try {
            rowPanel.add(Box.createRigidArea(dim));
            cnt++;
        } catch (NullPointerException npe) {
        /* never */
        }
    }
    if (rowPanel != null) {
        _iconPanel.add(rowPanel);
        _iconPanel.add(Box.createVerticalStrut(STRUT_SIZE));
    }
    rowPanel = new JPanel();
    rowPanel.setLayout(new BoxLayout(rowPanel, BoxLayout.X_AXIS));
    rowPanel.add(Box.createHorizontalStrut(STRUT_SIZE));
    JPanel panel = null;
    cnt = 0;
    for (int i = _order.size() - 1; i >= 0; i--) {
        if (panel == null) {
            panel = new JPanel();
            panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
            panel.add(Box.createHorizontalStrut(STRUT_SIZE));
        }
        String key = _order.get(i);
        JPanel p = new JPanel();
        p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
        p.add(new JLabel(Bundle.getMessage(key)));
        p.add(_iconMap.get(key));
        panel.add(p);
        panel.add(Box.createHorizontalStrut(STRUT_SIZE));
        if ((cnt & 1) != 0) {
            _iconPanel.add(panel);
            _iconPanel.add(Box.createVerticalStrut(STRUT_SIZE));
            panel = null;
        }
        cnt++;
    }
    if (panel != null) {
        _iconPanel.add(panel);
        _iconPanel.add(Box.createVerticalStrut(STRUT_SIZE));
    }
    this.add(_iconPanel, 0);
    valueChanged(null);
    pack();
}
Also used : JPanel(javax.swing.JPanel) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) Turnout(jmri.Turnout)

Aggregations

ButtonGroup (javax.swing.ButtonGroup)339 JPanel (javax.swing.JPanel)202 JRadioButton (javax.swing.JRadioButton)186 JLabel (javax.swing.JLabel)148 ActionEvent (java.awt.event.ActionEvent)134 ActionListener (java.awt.event.ActionListener)118 BoxLayout (javax.swing.BoxLayout)83 GridBagLayout (java.awt.GridBagLayout)81 JButton (javax.swing.JButton)75 JTextField (javax.swing.JTextField)70 JMenu (javax.swing.JMenu)69 GridBagConstraints (java.awt.GridBagConstraints)67 BorderLayout (java.awt.BorderLayout)64 Insets (java.awt.Insets)64 Dimension (java.awt.Dimension)58 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)57 FlowLayout (java.awt.FlowLayout)53 JMenuItem (javax.swing.JMenuItem)50 JCheckBox (javax.swing.JCheckBox)47 JScrollPane (javax.swing.JScrollPane)47