Search in sources :

Example 96 with JToggleButton

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

the class CombinedLocoSelPane method layoutRosterSelection.

/**
     * Create the panel used to select an existing entry
     *
     * @return a JPanel for handling the entry-selection GUI
     */
protected JPanel layoutRosterSelection() {
    JPanel pane2a = new JPanel();
    pane2a.setLayout(new BoxLayout(pane2a, BoxLayout.X_AXIS));
    pane2a.add(new JLabel(Bundle.getMessage("USE LOCOMOTIVE SETTINGS FOR:")));
    locoBox.setNonSelectedItem(Bundle.getMessage("<NONE - NEW LOCO>"));
    Roster.getDefault().addPropertyChangeListener(this);
    pane2a.add(locoBox);
    locoBox.addPropertyChangeListener(RosterEntrySelector.SELECTED_ROSTER_ENTRIES, new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent pce) {
            if (locoBox.getSelectedRosterEntries().length != 0) {
                // reset and disable decoder selection
                setDecoderSelectionFromLoco(locoBox.getSelectedRosterEntries()[0].titleString());
                go2.setEnabled(true);
                go2.setRequestFocusEnabled(true);
                go2.requestFocus();
                go2.setToolTipText(Bundle.getMessage("TipClickToOpen"));
            } else {
                go2.setEnabled(false);
                go2.setToolTipText(Bundle.getMessage("TipSelectLoco"));
            }
        }
    });
    idloco = new JToggleButton(Bundle.getMessage("IDENT"));
    idloco.setToolTipText(Bundle.getMessage("READ THE LOCOMOTIVE'S ADDRESS AND ATTEMPT TO SELECT THE RIGHT SETTINGS"));
    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
        idloco.setEnabled(false);
        idloco.setToolTipText(Bundle.getMessage("BUTTON DISABLED BECAUSE CONFIGURED COMMAND STATION CAN'T READ CVS"));
    }
    idloco.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            if (log.isDebugEnabled()) {
                log.debug("Identify locomotive pressed");
            }
            startIdentifyLoco();
        }
    });
    pane2a.add(idloco);
    pane2a.setAlignmentX(JLabel.RIGHT_ALIGNMENT);
    return pane2a;
}
Also used : JPanel(javax.swing.JPanel) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener)

Example 97 with JToggleButton

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

the class DieselPane method initComponents.

/**
     * Build teh GUI components
     */
@Override
public void initComponents() {
    listenerList = new javax.swing.event.EventListenerList();
    this.setLayout(new GridLayout(0, 2));
    //Set up the throttle spinner
    throttle_spinner = new JSpinner(new SpinnerNumberModel(THROTTLE_INIT, THROTTLE_MIN, THROTTLE_MAX, 1));
    throttle_spinner.setToolTipText(Bundle.getMessage("ToolTipDP_ThrottleSpinner"));
    throttle_spinner.setEnabled(false);
    this.add(throttle_spinner);
    // Setup the start button
    start_button = new JToggleButton();
    start_button.setText(Bundle.getMessage("ButtonEngineStart"));
    start_button.setToolTipText(Bundle.getMessage("ToolTipDP_StartButton"));
    start_button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            startButtonChange(e);
        }
    });
    this.add(start_button);
    this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    this.setVisible(true);
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) GridLayout(java.awt.GridLayout) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JSpinner(javax.swing.JSpinner)

Example 98 with JToggleButton

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

the class Ds64TabbedPanel method initComponents.

@Override
public void initComponents() {
    super.initComponents();
    // implements an AbstractBoardProgPanel with three tabs:
    //      Outputs tab - configure features most related to DS64 outputs
    //      Inputs tab - configure features most related to DS64 inputs
    //      Routes tab - configure features related to routes
    //          Routes tab has sub-tabs, one for each of the 8 routes
    addrField.setText(Bundle.getMessage("LABEL_UNIT_ADDRESS"));
    String[] outputTypes = { Bundle.getMessage("ComboBoxOutputType0"), Bundle.getMessage("ComboBoxOutputType1") };
    outputTypeLabel = new JLabel(Bundle.getMessage("LabelOutputType"));
    // opSw 1
    outputType = new JComboBox<>(outputTypes);
    outputType.setToolTipText(Bundle.getMessage("ToolTipOutputType"));
    outputType.addActionListener(basicConfigChangeActionListener);
    // NOI18N
    outputType.setName("1");
    String[] availableDelayTimes = new String[16];
    availableDelayTimes[0] = Bundle.getMessage("ComboBoxPulseTime0point1");
    availableDelayTimes[1] = Bundle.getMessage("ComboBoxPulseTime0point2");
    availableDelayTimes[2] = Bundle.getMessage("ComboBoxPulseTime0point4");
    availableDelayTimes[3] = Bundle.getMessage("ComboBoxPulseTime0point6");
    availableDelayTimes[4] = Bundle.getMessage("ComboBoxPulseTime0point8");
    availableDelayTimes[5] = Bundle.getMessage("ComboBoxPulseTime1point0");
    availableDelayTimes[6] = Bundle.getMessage("ComboBoxPulseTime1point2");
    availableDelayTimes[7] = Bundle.getMessage("ComboBoxPulseTime1point4");
    availableDelayTimes[8] = Bundle.getMessage("ComboBoxPulseTime1point6");
    availableDelayTimes[9] = Bundle.getMessage("ComboBoxPulseTime1point8");
    availableDelayTimes[10] = Bundle.getMessage("ComboBoxPulseTime2point0");
    availableDelayTimes[11] = Bundle.getMessage("ComboBoxPulseTime2point2");
    availableDelayTimes[12] = Bundle.getMessage("ComboBoxPulseTime2point4");
    availableDelayTimes[13] = Bundle.getMessage("ComboBoxPulseTime2point6");
    availableDelayTimes[14] = Bundle.getMessage("ComboBoxPulseTime2point8");
    availableDelayTimes[15] = Bundle.getMessage("ComboBoxPulseTime3point0");
    // opSws 2-5
    delayTimeLabel = new JLabel(Bundle.getMessage("LabelPulseTimeout"));
    delayTime = new JComboBox<>(availableDelayTimes);
    delayTime.setToolTipText(Bundle.getMessage("ToolTipPulseTimeout"));
    // NOI18N
    delayTime.setName("2345");
    delayTime.addActionListener(basicConfigChangeActionListener);
    String[] initialOutputStates = { Bundle.getMessage("ComboBoxOutputPowerupType0"), Bundle.getMessage("ComboBoxOutputPowerupType1") };
    outputStatesLabel = new JLabel(Bundle.getMessage("LabelPowerUpOutputActivity"));
    // opsw 6
    outputStates = new JComboBox<>(initialOutputStates);
    outputStates.setToolTipText(Bundle.getMessage("ToolTipOutputStates"));
    // NOI18N
    outputStates.setName("6");
    outputStates.addActionListener(basicConfigChangeActionListener);
    String[] startupDelays = { Bundle.getMessage("ComboBoxOutputPowerupDelayType0"), Bundle.getMessage("ComboBoxOutputPowerupDelayType1") };
    startupDelayLabel = new JLabel(Bundle.getMessage("LabelInitialPowerUpDelay"));
    // opsw 8
    startupDelay = new JComboBox<>(startupDelays);
    startupDelay.setToolTipText(Bundle.getMessage("ToolTipStartupDelay"));
    // NOI18N
    startupDelay.setName("8");
    startupDelay.addActionListener(basicConfigChangeActionListener);
    String[] staticOutputShutoffs = { Bundle.getMessage("ComboBoxOutputPowerManagementType0"), Bundle.getMessage("ComboBoxOutputPowerManagementType1") };
    staticOutputShutoffLabel = new JLabel(Bundle.getMessage("LabelOutputPowerManagementStyle"));
    // opSw 9
    staticOutputShutoff = new JComboBox<>(staticOutputShutoffs);
    staticOutputShutoff.setToolTipText(Bundle.getMessage("ToolTipLabelOutputPowerManagementStyle"));
    // NOI18N
    staticOutputShutoff.setName("9");
    staticOutputShutoff.addActionListener(basicConfigChangeActionListener);
    // command sources
    String[] commandTypes = { Bundle.getMessage("ComboBoxCommandsRecognizedFromType0"), Bundle.getMessage("ComboBoxCommandsRecognizedFromType1") };
    commandTypeLabel = new JLabel(Bundle.getMessage("LabelAcceptedSwitchCommandTypes"));
    //opSw 10
    commandType = new JComboBox<>(commandTypes);
    commandType.setToolTipText(Bundle.getMessage("ToolTipLabelAcceptedSwitchCommandTypes"));
    // NOI18N
    commandType.setName("10");
    commandType.addActionListener(basicConfigChangeActionListener);
    String[] commandSources = { Bundle.getMessage("ComboBoxCommandSourceType0"), Bundle.getMessage("ComboBoxCommandSourceType1") };
    commandSourceLabel = new JLabel(Bundle.getMessage("LabelAcceptSwitchCommandsFrom"));
    // opSw14
    commandSource = new JComboBox<>(commandSources);
    commandSource.setToolTipText(Bundle.getMessage("ToolTipCommandSource"));
    // NOI18N
    commandSource.setName("14");
    commandSource.addActionListener(basicConfigChangeActionListener);
    // Crossbuck Flasher controls
    output1CrossbuckFlasherCheckBox = new JCheckBox(Bundle.getMessage("CheckBoxOutput1Crossbuck"));
    output1CrossbuckFlasherCheckBox.setToolTipText(Bundle.getMessage("ToolTipCheckBoxOutput1Crossbuck"));
    // NOI18N
    output1CrossbuckFlasherCheckBox.setName("17");
    output1CrossbuckFlasherCheckBox.addActionListener(basicConfigChangeActionListener);
    output2CrossbuckFlasherCheckBox = new JCheckBox(Bundle.getMessage("CheckBoxOutput2Crossbuck"));
    output2CrossbuckFlasherCheckBox.setToolTipText(Bundle.getMessage("ToolTipCheckBoxOutput2Crossbuck"));
    // NOI18N
    output2CrossbuckFlasherCheckBox.setName("18");
    output2CrossbuckFlasherCheckBox.addActionListener(basicConfigChangeActionListener);
    output3CrossbuckFlasherCheckBox = new JCheckBox(Bundle.getMessage("CheckBoxOutput3Crossbuck"));
    output3CrossbuckFlasherCheckBox.setToolTipText(Bundle.getMessage("ToolTipCheckBoxOutput3Crossbuck"));
    // NOI18N
    output3CrossbuckFlasherCheckBox.setName("19");
    output3CrossbuckFlasherCheckBox.addActionListener(basicConfigChangeActionListener);
    output4CrossbuckFlasherCheckBox = new JCheckBox(Bundle.getMessage("CheckBoxOutput4Crossbuck"));
    output4CrossbuckFlasherCheckBox.setToolTipText(Bundle.getMessage("ToolTipCheckBoxOutput4Crossbuck"));
    // NOI18N
    output4CrossbuckFlasherCheckBox.setName("20");
    output4CrossbuckFlasherCheckBox.addActionListener(basicConfigChangeActionListener);
    // DS64 routes
    String[] routesControls = { Bundle.getMessage("ComboBoxEntryRoutesOption0"), Bundle.getMessage("ComboBoxEntryRoutesOption1"), Bundle.getMessage("ComboBoxEntryRoutesOption2"), Bundle.getMessage("ComboBoxEntryRoutesOption3") };
    routesControlLabel = new JLabel(Bundle.getMessage("LabelTriggerDs64Routes"));
    // opSws 11, 16
    routesControl = new JComboBox<>(routesControls);
    routesControl.setToolTipText(Bundle.getMessage("ToolTipLabelRouteControlOptions"));
    // NOI18N
    routesControl.setName("1116");
    routesControl.addActionListener(basicConfigChangeActionListener);
    // local input controls
    String[] localControlOfOutputsStyles = { Bundle.getMessage("ComboBoxInputsControlOutputsType0"), Bundle.getMessage("ComboBoxInputsControlOutputsType1"), Bundle.getMessage("ComboBoxInputsControlOutputsType2"), Bundle.getMessage("comboboxInputsControlOutputsType3") };
    localControlOfOutputsStyleLabel = new JLabel(Bundle.getMessage("LabelLocalInputsControlOutputs"));
    // opSw12
    localControlOfOutputsStyle = new JComboBox<>(localControlOfOutputsStyles);
    localControlOfOutputsStyle.setToolTipText(Bundle.getMessage("ToolTipLocalInputsControl"));
    // NOI18N
    localControlOfOutputsStyle.setName("1215");
    localControlOfOutputsStyle.addActionListener(basicConfigChangeActionListener);
    String[] sensorMessageTriggers = { Bundle.getMessage("ComboBoxInputsCauseMessagesType0"), Bundle.getMessage("ComboBoxInputsCauseMessagesType1") };
    sensorMessageTriggerLabel = new JLabel(Bundle.getMessage("LabelBetweenForMessageTypeSent"));
    // opSw13
    sensorMessageTrigger = new JComboBox<>(sensorMessageTriggers);
    sensorMessageTrigger.setToolTipText(Bundle.getMessage("ToolTipSensorMessageTrigger"));
    // NOI18N
    sensorMessageTrigger.setName("13");
    sensorMessageTrigger.addActionListener(basicConfigChangeActionListener);
    String[] localSensorTypes = { Bundle.getMessage("ComboBoxSensorMessageTypeSentType0"), Bundle.getMessage("ComboBoxSensorMessageTypeSentType1") };
    // opSw21
    localSensorType = new JComboBox<>(localSensorTypes);
    localSensorType.setToolTipText(Bundle.getMessage("ToolTipLocalSensorsType"));
    // NOI18N
    localSensorType.setName("21");
    localSensorType.addActionListener(basicConfigChangeActionListener);
    factoryResetButton = new JToggleButton(Bundle.getMessage("ButtonTextResetToFactoryDefault"));
    factoryResetButton.setToolTipText(Bundle.getMessage("ToolTipButtonTextResetToFactoryDefault"));
    factoryResetButton.addActionListener(event -> {
        readAllButton.setEnabled(false);
        writeAllButton.setEnabled(false);
        resetRouteButton.setEnabled(false);
        boardFactoryReset();
    });
    routesTabbedPane = new JTabbedPane();
    routePanel = new JPanel[9];
    routeTop = new SimpleTurnoutStateEntry[9];
    routeA2 = new SimpleTurnoutStateEntry[9];
    routeA3 = new SimpleTurnoutStateEntry[9];
    routeA4 = new SimpleTurnoutStateEntry[9];
    routeA5 = new SimpleTurnoutStateEntry[9];
    routeA6 = new SimpleTurnoutStateEntry[9];
    routeA7 = new SimpleTurnoutStateEntry[9];
    routeA8 = new SimpleTurnoutStateEntry[9];
    resetRouteButton = new JToggleButton(Bundle.getMessage("ButtonTextResetRoute"));
    resetRouteButton.setToolTipText(Bundle.getMessage("ToolTipButtonTextResetRoute"));
    resetRouteButton.setEnabled(false);
    resetRouteButton.setVisible(false);
    // create read/write buttons, address
    JPanel addressingPanel = provideAddressing(" ");
    readAllButton.setPreferredSize(null);
    readAllButton.setText(Bundle.getMessage("ButtonTextReadFullSheet"));
    readAllButton.setToolTipText(Bundle.getMessage("ToolTipButtonTextReadFullSheet"));
    writeAllButton.setPreferredSize(null);
    writeAllButton.setText(Bundle.getMessage("ButtonTextWriteFullSheet"));
    writeAllButton.setToolTipText(Bundle.getMessage("ToolTipButtonTextWriteFullSheet"));
    // make both buttons a little bit bigger, with identical (preferred) sizes
    // (width increased because some computers/displays trim the button text)
    java.awt.Dimension d = writeAllButton.getPreferredSize();
    int w = d.width;
    d = readAllButton.getPreferredSize();
    if (d.width > w) {
        w = d.width;
    }
    writeAllButton.setPreferredSize(new java.awt.Dimension((int) (w * 1.1), d.height));
    readAllButton.setPreferredSize(new java.awt.Dimension((int) (w * 1.1), d.height));
    addressingPanel.add(resetRouteButton);
    int indexOfTargetBoardAddress = 0;
    addressComboBox = new JComboBox<>();
    for (Integer index = 0; index < boardNumsEntryValue.size(); ++index) {
        if (boardNumsEntryValue.get(index) == origAccessBoardNum) {
            origAccessBoardNum = -1;
            indexOfTargetBoardAddress = index;
        }
        addressComboBox.addItem(boardNumsEntryValue.get(index));
    }
    addressComboBox.setSelectedIndex(indexOfTargetBoardAddress);
    addressingPanel.add(addressComboBox, 1);
    addressingPanel.getComponent(2).setVisible(false);
    addressComboBox.setEditable(true);
    // add read/write buttons, address
    appendLine(addressingPanel);
    generalTabbedPane = new JTabbedPane();
    generalPanel = new JPanel();
    generalPanel.setLayout(new BoxLayout(generalPanel, BoxLayout.Y_AXIS));
    // NOI18N
    generalPanel.setName("Basic Settings");
    JPanel allOutputControls = new JPanel();
    allOutputControls.setLayout(new BoxLayout(allOutputControls, BoxLayout.Y_AXIS));
    javax.swing.border.TitledBorder allOutputControlsTitleBorder;
    javax.swing.border.Border blackline;
    blackline = javax.swing.BorderFactory.createLineBorder(java.awt.Color.black);
    allOutputControlsTitleBorder = javax.swing.BorderFactory.createTitledBorder(blackline, Bundle.getMessage("TitledBorderLabelOutputControls"));
    allOutputControls.setBorder(allOutputControlsTitleBorder);
    JPanel outputTypePanel = new JPanel();
    outputTypePanel.setLayout(new FlowLayout());
    outputTypePanel.add(outputTypeLabel);
    outputTypePanel.add(outputType);
    allOutputControls.add(outputTypePanel);
    JPanel delayTimePanel = new JPanel();
    delayTimePanel.setLayout(new FlowLayout());
    delayTimePanel.add(delayTimeLabel);
    delayTimePanel.add(delayTime);
    allOutputControls.add(delayTimePanel);
    JPanel outputStatePanel = new JPanel();
    outputStatePanel.setLayout(new FlowLayout());
    outputStatePanel.add(outputStatesLabel);
    outputStatePanel.add(outputStates);
    allOutputControls.add(outputStatePanel);
    JPanel startupDelayPanel = new JPanel();
    startupDelayPanel.setLayout(new FlowLayout());
    startupDelayPanel.add(startupDelayLabel);
    startupDelayPanel.add(startupDelay);
    allOutputControls.add(startupDelayPanel);
    JPanel staticOutputShutoffPanel = new JPanel();
    staticOutputShutoffPanel.setLayout(new FlowLayout());
    staticOutputShutoffPanel.add(staticOutputShutoffLabel);
    staticOutputShutoffPanel.add(staticOutputShutoff);
    allOutputControls.add(staticOutputShutoffPanel);
    JPanel crossingGateControls = new JPanel(new java.awt.GridLayout(2, 2));
    crossingGateControls.add(output1CrossbuckFlasherCheckBox);
    crossingGateControls.add(output2CrossbuckFlasherCheckBox);
    crossingGateControls.add(output3CrossbuckFlasherCheckBox);
    crossingGateControls.add(output4CrossbuckFlasherCheckBox);
    allOutputControls.add(crossingGateControls);
    generalPanel.add(allOutputControls);
    // command sources
    JPanel ds64CommandSourcesPanel = new JPanel();
    ds64CommandSourcesPanel.setLayout(new BoxLayout(ds64CommandSourcesPanel, BoxLayout.Y_AXIS));
    javax.swing.border.TitledBorder ds64CommandSourcesTitleBorder;
    ds64CommandSourcesTitleBorder = javax.swing.BorderFactory.createTitledBorder(blackline, Bundle.getMessage("TitledBorderLabelCommandSources"));
    ds64CommandSourcesPanel.setBorder(ds64CommandSourcesTitleBorder);
    JPanel commandTypePanel = new JPanel();
    commandTypePanel.setLayout(new FlowLayout());
    commandTypePanel.add(commandTypeLabel);
    commandTypePanel.add(commandType);
    ds64CommandSourcesPanel.add(commandTypePanel);
    JPanel commandSourcePanel = new JPanel();
    commandSourcePanel.setLayout(new FlowLayout());
    commandSourcePanel.add(commandSourceLabel);
    commandSourcePanel.add(commandSource);
    ds64CommandSourcesPanel.add(commandSourcePanel);
    generalPanel.add(ds64CommandSourcesPanel);
    // DS64 routes
    JPanel localRoutesPanel = new JPanel();
    localRoutesPanel.setLayout(new BoxLayout(localRoutesPanel, BoxLayout.Y_AXIS));
    javax.swing.border.TitledBorder localRoutesTitleBorder;
    localRoutesTitleBorder = javax.swing.BorderFactory.createTitledBorder(blackline, Bundle.getMessage("TitledBorderLabelRoutes"));
    localRoutesPanel.setBorder(localRoutesTitleBorder);
    JPanel routesControlPanel = new JPanel();
    routesControlPanel.setLayout(new FlowLayout());
    routesControlPanel.add(routesControlLabel);
    routesControlPanel.add(routesControl);
    localRoutesPanel.add(routesControlPanel);
    generalPanel.add(localRoutesPanel);
    // local input controls
    localInputControlsPanel = new JPanel();
    localInputControlsPanel.setLayout(new BoxLayout(localInputControlsPanel, BoxLayout.Y_AXIS));
    javax.swing.border.TitledBorder localInputControlsTitleBorder;
    localInputControlsTitleBorder = javax.swing.BorderFactory.createTitledBorder(blackline, Bundle.getMessage("TitledBorderLabelLocalInputControls"));
    localInputControlsPanel.setBorder(localInputControlsTitleBorder);
    JPanel localControlOfOutputsStylePanel = new JPanel(new FlowLayout());
    localControlOfOutputsStylePanel.add(localControlOfOutputsStyleLabel);
    localControlOfOutputsStylePanel.add(localControlOfOutputsStyle);
    localInputControlsPanel.add(localControlOfOutputsStylePanel);
    sensorMessageTriggerPanel = new JPanel(new FlowLayout());
    sensorMessageTriggerPanel.add(localSensorType);
    sensorMessageTriggerPanel.add(sensorMessageTriggerLabel);
    sensorMessageTriggerPanel.add(sensorMessageTrigger);
    localInputControlsPanel.add(sensorMessageTriggerPanel);
    generalPanel.add(localInputControlsPanel);
    generalPanel.add(new JSeparator());
    JPanel factoryResetButtonPanel = new JPanel();
    factoryResetButtonPanel.add(factoryResetButton);
    generalPanel.add(factoryResetButtonPanel);
    generalTabbedPane.addTab(Bundle.getMessage("TabTextBasicSettings"), null, generalPanel, Bundle.getMessage("TabToolTipBasicSettings"));
    // opsws panel
    opswsPanel = new JPanel();
    opswsValues = new JPanel();
    opswsValues.setLayout(new BoxLayout(opswsValues, BoxLayout.Y_AXIS));
    javax.swing.border.TitledBorder opswsValuesTitleBorder;
    opswsValuesTitleBorder = javax.swing.BorderFactory.createTitledBorder(blackline, Bundle.getMessage("TitledBorderLabelOpSws"));
    opswsValues.setBorder(opswsValuesTitleBorder);
    opswsPanel.setLayout(new BoxLayout(opswsPanel, BoxLayout.Y_AXIS));
    JPanel innerPanel;
    ButtonGroup[] g = new ButtonGroup[22];
    opswThrown = new JRadioButtonWithInteger[22];
    opswClosed = new JRadioButtonWithInteger[22];
    for (int i = 1; i <= 21; i++) {
        if (i != 7) {
            log.debug("Creating entry for OpSw " + i);
            innerPanel = new JPanel(new FlowLayout());
            // NOI18N
            innerPanel.add(new JLabel("OpSw " + i));
            opswThrown[i] = new JRadioButtonWithInteger(i, Bundle.getMessage("RadioButtonTextThrown"));
            opswClosed[i] = new JRadioButtonWithInteger(i, Bundle.getMessage("RadioButtonTextClosed"));
            g[i] = new ButtonGroup();
            g[i].add(opswThrown[i]);
            g[i].add(opswClosed[i]);
            innerPanel.add(opswThrown[i]);
            innerPanel.add(opswClosed[i]);
            opswsPanel.add(innerPanel);
            opswsPanel.add(new JSeparator());
            opswThrown[i].addItemListener(event -> {
                if (event.getSource().getClass().equals(JRadioButtonWithInteger.class)) {
                    JRadioButtonWithInteger source = ((JRadioButtonWithInteger) (event.getSource()));
                    int ind = source.index;
                    boolean st = (event.getStateChange() == ItemEvent.DESELECTED);
                    log.debug("ItemEventListener Opsw values: " + ind + " thrown radio button event: " + st + " " + (st ? "Closed" : "Thrown") + ".");
                    opsw[ind] = st;
                }
            });
        }
    }
    opswsValues.add(opswsPanel);
    opswsScrollPane = new JScrollPane(opswsValues);
    opswsScrollPane.setPreferredSize(new java.awt.Dimension(180, 200));
    // NOI18N
    opswsScrollPane.setName("Simple OpSws");
    generalTabbedPane.addTab(Bundle.getMessage("TabTextOpSwValues"), null, opswsScrollPane, Bundle.getMessage("TabToolTipOpSwValues"));
    outputAddrsPanel = new JPanel();
    outputAddrsPanel.setLayout(new BoxLayout(outputAddrsPanel, BoxLayout.Y_AXIS));
    JPanel p = new JPanel();
    p.setLayout(new FlowLayout());
    p.add(new JLabel(Bundle.getMessage("LabelCautionReadingWritingCanCauseOutputChanges")));
    outputAddrsPanel.add(p);
    p = new JPanel();
    p.setLayout(new FlowLayout());
    p.add(new JLabel(Bundle.getMessage("LabelTextOutput1")));
    outAddr1 = new ValidatedTextField(5, false, 1, 2048, Bundle.getMessage("ErrorTextNonBlankAddressInvalid"));
    outState1 = new JLabel(Bundle.getMessage("LabelTurnoutCurrentlyIsUnknown"));
    p.add(outAddr1);
    p.add(outState1);
    outputAddrsPanel.add(p);
    p = new JPanel();
    p.setLayout(new FlowLayout());
    p.add(new JLabel(Bundle.getMessage("LabelTextOutput2")));
    outAddr2 = new ValidatedTextField(5, false, 1, 2048, Bundle.getMessage("ErrorTextNonBlankAddressInvalid"));
    outState2 = new JLabel(Bundle.getMessage("LabelTurnoutCurrentlyIsUnknown"));
    p.add(outAddr2);
    p.add(outState2);
    outputAddrsPanel.add(p);
    p = new JPanel();
    p.setLayout(new FlowLayout());
    p.add(new JLabel(Bundle.getMessage("LabelTextOutput3")));
    outAddr3 = new ValidatedTextField(5, false, 1, 2048, Bundle.getMessage("ErrorTextNonBlankAddressInvalid"));
    outState3 = new JLabel(Bundle.getMessage("LabelTurnoutCurrentlyIsUnknown"));
    p.add(outAddr3);
    p.add(outState3);
    outputAddrsPanel.add(p);
    p = new JPanel();
    p.setLayout(new FlowLayout());
    p.add(new JLabel(Bundle.getMessage("LabelTextOutput4")));
    outAddr4 = new ValidatedTextField(5, false, 1, 2048, Bundle.getMessage("ErrorTextNonBlankAddressInvalid"));
    outState4 = new JLabel(Bundle.getMessage("LabelTurnoutCurrentlyIsUnknown"));
    p.add(outAddr4);
    p.add(outState4);
    outputAddrsPanel.add(p);
    outputAddrsPanel.add(new JSeparator());
    p = new JPanel();
    p.setLayout(new FlowLayout());
    p.add(new JLabel(Bundle.getMessage("LabelOutputsTabSensorNotes")));
    outputAddrsPanel.add(p);
    generalTabbedPane.addTab(Bundle.getMessage("TabTextOutputAddrs"), null, outputAddrsPanel, Bundle.getMessage("TabToolTipOutputAddrs"));
    routePanel[0] = new JPanel();
    routesTabbedPane.setTabPlacement(JTabbedPane.LEFT);
    // create route panels (one tab each for each of 8 routes)
    for (int i = 1; i <= 8; ++i) {
        routePanel[i] = new JPanel();
        routePanel[i].setLayout(new BoxLayout(routePanel[i], BoxLayout.Y_AXIS));
        routePanel[i].add(new JLabel(Bundle.getMessage("TabTextSpecificRoute", Integer.toString(i))));
        routePanel[i].add(new JSeparator());
        JPanel q = new JPanel(new FlowLayout());
        q.add(new JLabel(Bundle.getMessage("LabelCautionReadingWritingCanCauseOutputChanges")));
        routePanel[i].add(q);
        routePanel[i].add(new JSeparator());
        routeTop[i] = new SimpleTurnoutStateEntry(2048, false, true);
        routeA2[i] = new SimpleTurnoutStateEntry(2048, false, true);
        routeA3[i] = new SimpleTurnoutStateEntry(2048, false, true);
        routeA4[i] = new SimpleTurnoutStateEntry(2048, false, true);
        routeA5[i] = new SimpleTurnoutStateEntry(2048, false, true);
        routeA6[i] = new SimpleTurnoutStateEntry(2048, false, true);
        routeA7[i] = new SimpleTurnoutStateEntry(2048, false, true);
        routeA8[i] = new SimpleTurnoutStateEntry(2048, false, true);
        routePanel[i].add(routeTop[i].createEntryPanel(Bundle.getMessage("LabelTextRouteXSpecificTurnout", Bundle.getMessage("LabelTextRouteXTopTurnout"))));
        routePanel[i].add(routeA2[i].createEntryPanel(Bundle.getMessage("LabelTextRouteXSpecificTurnout", 2)));
        routePanel[i].add(routeA3[i].createEntryPanel(Bundle.getMessage("LabelTextRouteXSpecificTurnout", 3)));
        routePanel[i].add(routeA4[i].createEntryPanel(Bundle.getMessage("LabelTextRouteXSpecificTurnout", 4)));
        routePanel[i].add(routeA5[i].createEntryPanel(Bundle.getMessage("LabelTextRouteXSpecificTurnout", 5)));
        routePanel[i].add(routeA6[i].createEntryPanel(Bundle.getMessage("LabelTextRouteXSpecificTurnout", 6)));
        routePanel[i].add(routeA7[i].createEntryPanel(Bundle.getMessage("LabelTextRouteXSpecificTurnout", 7)));
        routePanel[i].add(routeA8[i].createEntryPanel(Bundle.getMessage("LabelTextRouteXSpecificTurnout", 8)));
        routesTabbedPane.addTab(Bundle.getMessage("TabTextSpecificRoute", Integer.toString(i)), null, routePanel[i], Bundle.getMessage("TabToolTipSpecificRoute", Integer.toString(i)));
    }
    generalTabbedPane.addTab(Bundle.getMessage("TabTextRoutes"), null, routesTabbedPane, Bundle.getMessage("ToolTipTabTextRoutes"));
    resetRouteButton.addActionListener(event -> {
        readAllButton.setEnabled(false);
        writeAllButton.setEnabled(false);
        factoryResetButton.setEnabled(false);
        Integer routeNumber = 0;
        if (((JTabbedPane) generalTabbedPane.getSelectedComponent()) != routesTabbedPane) {
            return;
        }
        if (((JPanel) routesTabbedPane.getSelectedComponent()) == routePanel[1]) {
            routeNumber = 1;
        } else if (((JPanel) routesTabbedPane.getSelectedComponent()) == routePanel[2]) {
            routeNumber = 2;
        } else if (((JPanel) routesTabbedPane.getSelectedComponent()) == routePanel[3]) {
            routeNumber = 3;
        } else if (((JPanel) routesTabbedPane.getSelectedComponent()) == routePanel[4]) {
            routeNumber = 4;
        } else if (((JPanel) routesTabbedPane.getSelectedComponent()) == routePanel[5]) {
            routeNumber = 5;
        } else if (((JPanel) routesTabbedPane.getSelectedComponent()) == routePanel[6]) {
            routeNumber = 6;
        } else if (((JPanel) routesTabbedPane.getSelectedComponent()) == routePanel[7]) {
            routeNumber = 7;
        } else if (((JPanel) routesTabbedPane.getSelectedComponent()) == routePanel[8]) {
            routeNumber = 8;
        }
        if (routeNumber != 0) {
            Object[] dialogBoxButtonOptions = { Bundle.getMessage("ButtonTextResetRouteN", routeNumber), Bundle.getMessage("ButtonTextCancelBoardReset") };
            int userReply = JOptionPane.showOptionDialog(this.getParent(), Bundle.getMessage("DialogTextClearRouteWarning", routeNumber), Bundle.getMessage("DialogHeadingClearRouteWarning"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, dialogBoxButtonOptions, dialogBoxButtonOptions[1]);
            if (userReply != 0) {
                resetRouteButton.setSelected(false);
                return;
            }
            resetRouteOperation(routeNumber);
        }
        readAllButton.setEnabled(true);
        writeAllButton.setEnabled(true);
        factoryResetButton.setEnabled(true);
        resetRouteButton.setSelected(false);
    });
    appendLine(generalTabbedPane);
    JPanel statusPanel = new JPanel();
    setStatus(" ");
    statusPanel.add(new JSeparator());
    statusPanel.add(provideStatusLine());
    statusPanel.add(new JSeparator());
    appendLine(statusPanel);
    // configure DS64 message type
    setTypeWord(0x73);
    opsw[7] = false;
    operationType = OpSwOpType.BasicsRead;
    routesTabbedPane.addChangeListener(new ChangeListener() {

        // This method is called whenever the selected tab changes
        String route1TabText = Bundle.getMessage("TabTextSpecificRoute", Integer.toString(1));

        String route2TabText = Bundle.getMessage("TabTextSpecificRoute", Integer.toString(2));

        String route3TabText = Bundle.getMessage("TabTextSpecificRoute", Integer.toString(3));

        String route4TabText = Bundle.getMessage("TabTextSpecificRoute", Integer.toString(4));

        String route5TabText = Bundle.getMessage("TabTextSpecificRoute", Integer.toString(5));

        String route6TabText = Bundle.getMessage("TabTextSpecificRoute", Integer.toString(6));

        String route7TabText = Bundle.getMessage("TabTextSpecificRoute", Integer.toString(7));

        String route8TabText = Bundle.getMessage("TabTextSpecificRoute", Integer.toString(8));

        @Override
        public void stateChanged(ChangeEvent evt) {
            unhighlightAllBasicOpSws();
            unhighlightAllOutputEntryFields();
            unhighlightAllRouteEntryFields();
            String activeTabTitle = routesTabbedPane.getTitleAt(routesTabbedPane.getSelectedIndex());
            if ((activeTabTitle.equals(route1TabText)) || (activeTabTitle.equals(route2TabText)) || (activeTabTitle.equals(route3TabText)) || (activeTabTitle.equals(route4TabText)) || (activeTabTitle.equals(route5TabText)) || (activeTabTitle.equals(route6TabText)) || (activeTabTitle.equals(route7TabText)) || (activeTabTitle.equals(route8TabText))) {
                resetRouteButton.setVisible(true);
                resetRouteButton.setEnabled(true);
                resetRouteButton.updateUI();
                readAllButton.setSelected(false);
                readAllButton.updateUI();
                updateUI();
            }
        }
    });
    generalTabbedPane.addChangeListener(new ChangeListener() {

        // This method is called whenever the selected tab changes
        String route1TabText = Bundle.getMessage("TabTextSpecificRoute", Integer.toString(1));

        String route2TabText = Bundle.getMessage("TabTextSpecificRoute", Integer.toString(2));

        String route3TabText = Bundle.getMessage("TabTextSpecificRoute", Integer.toString(3));

        String route4TabText = Bundle.getMessage("TabTextSpecificRoute", Integer.toString(4));

        String route5TabText = Bundle.getMessage("TabTextSpecificRoute", Integer.toString(5));

        String route6TabText = Bundle.getMessage("TabTextSpecificRoute", Integer.toString(6));

        String route7TabText = Bundle.getMessage("TabTextSpecificRoute", Integer.toString(7));

        String route8TabText = Bundle.getMessage("TabTextSpecificRoute", Integer.toString(8));

        String outputsTabText = Bundle.getMessage("TabTextOutputAddrs");

        @Override
        public void stateChanged(ChangeEvent evt) {
            String activeTabTitle;
            unhighlightAllBasicOpSws();
            unhighlightAllOutputEntryFields();
            unhighlightAllRouteEntryFields();
            activeTabTitle = generalTabbedPane.getTitleAt(generalTabbedPane.getSelectedIndex());
            JTabbedPane pane = (JTabbedPane) evt.getSource();
            // Get current tab
            if ((activeTabTitle.equals(Bundle.getMessage("TabTextRoutes")))) {
                activeTabTitle = routesTabbedPane.getTitleAt(routesTabbedPane.getSelectedIndex());
                if ((activeTabTitle.equals(route1TabText)) || (activeTabTitle.equals(route2TabText)) || (activeTabTitle.equals(route3TabText)) || (activeTabTitle.equals(route4TabText)) || (activeTabTitle.equals(route5TabText)) || (activeTabTitle.equals(route6TabText)) || (activeTabTitle.equals(route7TabText)) || (activeTabTitle.equals(route8TabText))) {
                    resetRouteButton.setEnabled(true);
                    resetRouteButton.setVisible(true);
                    readAllButton.setEnabled(true);
                    writeAllButton.setSelected(false);
                    readAllButton.setSelected(false);
                    writeAllButton.setEnabled(true);
                    factoryResetButton.setEnabled(true);
                    routesTabbedPane.updateUI();
                    updateUI();
                } else {
                    routesTabbedPane.setSelectedIndex(0);
                    routesTabbedPane.updateUI();
                }
            } else if (activeTabTitle.equals(outputsTabText)) {
                resetRouteButton.setEnabled(false);
                resetRouteButton.setVisible(false);
                readAllButton.setEnabled(true);
                writeAllButton.setSelected(false);
                readAllButton.setSelected(false);
                writeAllButton.setEnabled(true);
                readAllButton.updateUI();
                updateUI();
            } else {
                readAllButton.setEnabled(true);
                writeAllButton.setEnabled(true);
                writeAllButton.setSelected(false);
                readAllButton.setSelected(false);
                resetRouteButton.setVisible(false);
                resetRouteButton.setEnabled(false);
                readAllButton.updateUI();
                updateUI();
            }
            (pane.getRootPane().getParent()).setPreferredSize(null);
            ((Window) pane.getRootPane().getParent()).pack();
        }
    });
    responseTimer.addActionListener(routeResetResponseTimerListener);
    commandType.setToolTipText(Bundle.getMessage("ToolTipLabelAcceptedSwitchCommandTypes"));
    updateBasicOpSwTab();
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) JTabbedPane(javax.swing.JTabbedPane) BoxLayout(javax.swing.BoxLayout) JSeparator(javax.swing.JSeparator) JToggleButton(javax.swing.JToggleButton) ChangeListener(javax.swing.event.ChangeListener) JScrollPane(javax.swing.JScrollPane) JLabel(javax.swing.JLabel) JCheckBox(javax.swing.JCheckBox) ValidatedTextField(jmri.util.swing.ValidatedTextField) ChangeEvent(javax.swing.event.ChangeEvent) ButtonGroup(javax.swing.ButtonGroup)

Example 99 with JToggleButton

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

the class Z21ConfigFrame method getBroadcastFlagsPanel.

private JPanel getBroadcastFlagsPanel() {
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("BroadcastFlagsLabel")));
    panel.setLayout(new GridLayout(0, 1));
    XPressNetMessagesCheckBox = new JCheckBox(Bundle.getMessage("XPressNetMessagesFlagLabel"), cs.getXPressNetMessagesFlag());
    XPressNetMessagesCheckBox.setToolTipText(Bundle.getMessage("XPressNetMessagesFlagToolTip"));
    panel.add(XPressNetMessagesCheckBox);
    RMBusMessagesCheckBox = new JCheckBox(Bundle.getMessage("RMBusMessagesFlagLabel"), cs.getRMBusMessagesFlag());
    RMBusMessagesCheckBox.setToolTipText(Bundle.getMessage("RMBusMessagesFlagToolTip"));
    panel.add(RMBusMessagesCheckBox);
    SystemStatusMessagesCheckBox = new JCheckBox(Bundle.getMessage("SystemStatusMessagesFlagLabel"), cs.getSystemStatusMessagesFlag());
    SystemStatusMessagesCheckBox.setToolTipText(Bundle.getMessage("RMBusMessagesFlagToolTip"));
    panel.add(SystemStatusMessagesCheckBox);
    XPressNetLocomotiveMessagesCheckBox = new JCheckBox(Bundle.getMessage("XPressNetLocomotiveMessagesFlagLabel"), cs.getXPressNetLocomotiveMessagesFlag());
    XPressNetLocomotiveMessagesCheckBox.setToolTipText(Bundle.getMessage("XPressNetLocomotiveMessagesFlagToolTip"));
    panel.add(XPressNetLocomotiveMessagesCheckBox);
    RailComMessagesCheckBox = new JCheckBox(Bundle.getMessage("RailComMessagesFlagLabel"), cs.getRailComMessagesFlag());
    RailComMessagesCheckBox.setToolTipText(Bundle.getMessage("RailComMessagesFlagToolTip"));
    panel.add(RailComMessagesCheckBox);
    LocoNetMessagesCheckBox = new JCheckBox(Bundle.getMessage("LocoNetMessagesFlagLabel"), cs.getLocoNetMessagesFlag());
    LocoNetMessagesCheckBox.setToolTipText(Bundle.getMessage("LocoNetMessagesFlagToolTip"));
    panel.add(LocoNetMessagesCheckBox);
    LocoNetLocomotiveMessagesCheckBox = new JCheckBox(Bundle.getMessage("LocoNetLocomotiveMessagesFlagLabel"), cs.getLocoNetLocomotiveMessagesFlag());
    LocoNetLocomotiveMessagesCheckBox.setToolTipText(Bundle.getMessage("LocoNetLocomotiveMessagesFlagToolTip"));
    panel.add(LocoNetLocomotiveMessagesCheckBox);
    LocoNetTurnoutMessagesCheckBox = new JCheckBox(Bundle.getMessage("LocoNetTurnoutMessagesFlagLabel"), cs.getLocoNetTurnoutMessagesFlag());
    LocoNetTurnoutMessagesCheckBox.setToolTipText(Bundle.getMessage("LocoNetTurnoutMessagesFlagToolTip"));
    panel.add(LocoNetTurnoutMessagesCheckBox);
    LocoNetOccupancyMessagesCheckBox = new JCheckBox(Bundle.getMessage("LocoNetOccupancyMessagesFlagLabel"), cs.getLocoNetOccupancyMessagesFlag());
    LocoNetOccupancyMessagesCheckBox.setToolTipText(Bundle.getMessage("LocoNetOccupancyMessagesFlagToolTip"));
    panel.add(LocoNetOccupancyMessagesCheckBox);
    setSystemInfoButton = new JToggleButton("SetSystemInfoButtonLabel");
    setSystemInfoButton.setToolTipText(Bundle.getMessage("SetSystemInfoButtonToolTip"));
    // Add Get SystemInfo button handler
    setSystemInfoButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent a) {
            writeSystemInfo();
        }
    });
    panel.add(setSystemInfoButton);
    return panel;
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent)

Example 100 with JToggleButton

use of javax.swing.JToggleButton in project JWildfire by thargor6.

the class FlamesGPURenderInternalFrame method getInteractiveFullSizeButton.

public JToggleButton getInteractiveFullSizeButton() {
    if (interactiveFullSizeButton == null) {
        interactiveFullSizeButton = new JToggleButton();
        interactiveFullSizeButton.setSelected(true);
        interactiveFullSizeButton.setToolTipText("Switch to full render resolution");
        interactiveFullSizeButton.setText("Full");
        interactiveFullSizeButton.setPreferredSize(new Dimension(48, 24));
        interactiveFullSizeButton.setMnemonic(KeyEvent.VK_M);
        interactiveFullSizeButton.setMinimumSize(new Dimension(48, 24));
        interactiveFullSizeButton.setMaximumSize(new Dimension(32000, 24));
        interactiveFullSizeButton.setFont(Prefs.getPrefs().getFont("Dialog", Font.BOLD, 10));
        interactiveFullSizeButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                tinaController.getGpuRendererCtrl().fullRenderSizeButton_clicked();
            }
        });
    }
    return interactiveFullSizeButton;
}
Also used : JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) Dimension(java.awt.Dimension)

Aggregations

JToggleButton (javax.swing.JToggleButton)179 ActionEvent (java.awt.event.ActionEvent)92 ActionListener (java.awt.event.ActionListener)90 ImageIcon (javax.swing.ImageIcon)76 Dimension (java.awt.Dimension)69 JPanel (javax.swing.JPanel)58 JButton (javax.swing.JButton)46 JLabel (javax.swing.JLabel)39 Point (java.awt.Point)29 JScrollPane (javax.swing.JScrollPane)19 BorderLayout (java.awt.BorderLayout)17 ChangeEvent (javax.swing.event.ChangeEvent)15 Insets (java.awt.Insets)14 ItemEvent (java.awt.event.ItemEvent)14 ChangeListener (javax.swing.event.ChangeListener)14 ItemListener (java.awt.event.ItemListener)13 Component (java.awt.Component)12 FlowLayout (java.awt.FlowLayout)12 BoxLayout (javax.swing.BoxLayout)12 JToolBar (javax.swing.JToolBar)12