Search in sources :

Example 21 with JFormattedTextField

use of javax.swing.JFormattedTextField in project EnrichmentMapApp by BaderLab.

the class EdgeWidthDialog method createGenesetOverlapPanel.

private JPanel createGenesetOverlapPanel() {
    JPanel panel = new JPanel();
    panel.setBorder(LookAndFeelUtil.createTitledBorder("Geneset Overlap"));
    panel.setLayout(new GridBagLayout());
    GridBagConstraints gbc;
    // Similarity Coefficient
    JLabel similarityLabel = new JLabel("Similarity Coefficient:    ");
    gbc = gridBagConstraints(0, 0);
    gbc.weightx = 1.0;
    panel.add(similarityLabel, gbc);
    JLabel lowerBound = new JLabel(String.format("%.1f", similarityCutoff));
    lowerBound.setHorizontalAlignment(JLabel.RIGHT);
    gbc = gridBagConstraints(1, 0);
    panel.add(lowerBound, gbc);
    // hardcoded
    JLabel upperBound = new JLabel("1.0");
    upperBound.setHorizontalAlignment(JLabel.RIGHT);
    gbc = gridBagConstraints(2, 0);
    panel.add(upperBound, gbc);
    JLabel spacer = new JLabel("");
    gbc = gridBagConstraints(3, 0);
    panel.add(spacer, gbc);
    // Width
    JLabel widthLabel = new JLabel("Width:");
    gbc = gridBagConstraints(0, 1);
    panel.add(widthLabel, gbc);
    emLowerWidthText = new JFormattedTextField(new DecimalFormat());
    emLowerWidthText.setPreferredSize(new Dimension(50, emLowerWidthText.getPreferredSize().height));
    emLowerWidthText.setHorizontalAlignment(JTextField.RIGHT);
    gbc = gridBagConstraints(1, 1);
    gbc.insets = new Insets(5, 5, 5, 0);
    panel.add(emLowerWidthText, gbc);
    emUpperWidthText = new JFormattedTextField(new DecimalFormat());
    emUpperWidthText.setPreferredSize(new Dimension(50, emUpperWidthText.getPreferredSize().height));
    emUpperWidthText.setHorizontalAlignment(JTextField.RIGHT);
    gbc = gridBagConstraints(2, 1);
    gbc.insets = new Insets(5, 5, 5, 0);
    panel.add(emUpperWidthText, gbc);
    JLabel mappingText = new JLabel("(continuous mapping) ");
    gbc = gridBagConstraints(3, 1);
    panel.add(mappingText, gbc);
    makeSmall(similarityLabel, lowerBound, upperBound, spacer, widthLabel, emLowerWidthText, emUpperWidthText, mappingText);
    return panel;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) DecimalFormat(java.text.DecimalFormat) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension)

Example 22 with JFormattedTextField

use of javax.swing.JFormattedTextField 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 23 with JFormattedTextField

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

the class ClientActions method openCdiWindow.

public void openCdiWindow(NodeID destNode, String description) {
    final java.util.ArrayList<JButton> readList = new java.util.ArrayList<JButton>();
    final java.util.ArrayList<JButton> sensorButtonList = new java.util.ArrayList<JButton>();
    final java.util.ArrayList<JButton> turnoutButtonList = new java.util.ArrayList<JButton>();
    JmriJFrame f = new JmriJFrame();
    f.setTitle(Bundle.getMessage("CdiPanelConfigure", description));
    f.setLayout(new javax.swing.BoxLayout(f.getContentPane(), javax.swing.BoxLayout.Y_AXIS));
    CdiPanel m = new CdiPanel();
    f.add(m);
    m.setEventTable(iface.getNodeStore().getSimpleNodeIdent(destNode).getUserName(), iface.getEventTable());
    // create an object to add "New Sensor" buttons
    CdiPanel.GuiItemFactory factory = new CdiPanel.GuiItemFactory() {

        private boolean haveButtons = false;

        @Override
        public JButton handleReadButton(JButton button) {
            readList.add(button);
            return button;
        }

        @Override
        public JButton handleWriteButton(JButton button) {
            return button;
        }

        @Override
        public void handleGroupPaneStart(JPanel pane) {
            this.gpane = pane;
            evt1 = null;
            evt2 = null;
            desc = null;
            return;
        }

        @Override
        public void handleGroupPaneEnd(JPanel pane) {
            if (gpane != null && evt1 != null && evt2 != null && desc != null) {
                JPanel p = new JPanel();
                p.setLayout(new FlowLayout());
                p.setAlignmentX(-1.0f);
                pane.add(p);
                JButton button = new JButton(Bundle.getMessage("CdiPanelMakeSensor"));
                p.add(button);
                sensorButtonList.add(button);
                button.addActionListener(new java.awt.event.ActionListener() {

                    @Override
                    public void actionPerformed(java.awt.event.ActionEvent e) {
                        jmri.Sensor sensor = jmri.InstanceManager.sensorManagerInstance().provideSensor("MS" + mevt1.getText() + ";" + mevt2.getText());
                        if (mdesc.getText().length() > 0) {
                            sensor.setUserName(mdesc.getText());
                        }
                        log.info("make sensor MS" + mevt1.getText() + ";" + mevt2.getText() + " [" + mdesc.getText() + "]");
                    }

                    JTextField mdesc = desc;

                    JFormattedTextField mevt1 = evt1;

                    JFormattedTextField mevt2 = evt2;
                });
                button = new JButton(Bundle.getMessage("CdiPanelMakeTurnout"));
                p.add(button);
                turnoutButtonList.add(button);
                button.addActionListener(new java.awt.event.ActionListener() {

                    @Override
                    public void actionPerformed(java.awt.event.ActionEvent e) {
                        jmri.Turnout turnout = jmri.InstanceManager.turnoutManagerInstance().provideTurnout("MT" + mevt1.getText() + ";" + mevt2.getText());
                        if (mdesc.getText().length() > 0) {
                            turnout.setUserName(mdesc.getText());
                        }
                        log.info("make turnout MT" + mevt1.getText() + ";" + mevt2.getText() + " [" + mdesc.getText() + "]");
                    }

                    JTextField mdesc = desc;

                    JFormattedTextField mevt1 = evt1;

                    JFormattedTextField mevt2 = evt2;
                });
                if (!haveButtons) {
                    haveButtons = true;
                    m.addButtonToFooter(buttonForList(sensorButtonList, Bundle.getMessage("CdiPanelMakeAllSensors")));
                    m.addButtonToFooter(buttonForList(turnoutButtonList, Bundle.getMessage("CdiPanelMakeAllTurnouts")));
                }
                gpane = null;
                evt1 = null;
                evt2 = null;
                desc = null;
            }
            return;
        }

        @Override
        public JFormattedTextField handleEventIdTextField(JFormattedTextField field) {
            if (evt1 == null) {
                evt1 = field;
            } else if (evt2 == null) {
                evt2 = field;
            } else {
                // flag too many
                gpane = null;
            }
            return field;
        }

        @Override
        public JTextField handleStringValue(JTextField value) {
            desc = value;
            return value;
        }

        JPanel gpane = null;

        JTextField desc = null;

        JFormattedTextField evt1 = null;

        JFormattedTextField evt2 = null;
    };
    ConfigRepresentation rep = iface.getConfigForNode(destNode);
    m.initComponents(rep, factory);
    f.pack();
    f.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) CdiPanel(org.openlcb.cdi.swing.CdiPanel) FlowLayout(java.awt.FlowLayout) ActionListener(java.awt.event.ActionListener) JButton(javax.swing.JButton) JFormattedTextField(javax.swing.JFormattedTextField) JTextField(javax.swing.JTextField) ActionEvent(java.awt.event.ActionEvent) ConfigRepresentation(org.openlcb.cdi.impl.ConfigRepresentation) JmriJFrame(jmri.util.JmriJFrame)

Example 24 with JFormattedTextField

use of javax.swing.JFormattedTextField in project jgnash by ccavanaugh.

the class CheckDesignDialog method getFloatField.

private static JFormattedTextField getFloatField() {
    NumberFormatter df = new NumberFormatter(new DecimalFormat("#.##"));
    NumberFormatter ef = new NumberFormatter(new DecimalFormat("#.##"));
    return new JFormattedTextField(new DefaultFormatterFactory(df, df, ef));
}
Also used : DecimalFormat(java.text.DecimalFormat) JFormattedTextField(javax.swing.JFormattedTextField) DefaultFormatterFactory(javax.swing.text.DefaultFormatterFactory) NumberFormatter(javax.swing.text.NumberFormatter)

Example 25 with JFormattedTextField

use of javax.swing.JFormattedTextField in project jgnash by ccavanaugh.

the class CheckDesignDialog method getIntegerField.

private static JFormattedTextField getIntegerField() {
    NumberFormatter df = new NumberFormatter(new DecimalFormat("#"));
    NumberFormatter ef = new NumberFormatter(new DecimalFormat("#"));
    return new JFormattedTextField(new DefaultFormatterFactory(df, df, ef));
}
Also used : DecimalFormat(java.text.DecimalFormat) JFormattedTextField(javax.swing.JFormattedTextField) DefaultFormatterFactory(javax.swing.text.DefaultFormatterFactory) NumberFormatter(javax.swing.text.NumberFormatter)

Aggregations

JFormattedTextField (javax.swing.JFormattedTextField)43 JLabel (javax.swing.JLabel)15 JPanel (javax.swing.JPanel)14 DecimalFormat (java.text.DecimalFormat)9 ParseException (java.text.ParseException)9 PropertyChangeEvent (java.beans.PropertyChangeEvent)7 JButton (javax.swing.JButton)7 NumberFormatter (javax.swing.text.NumberFormatter)7 ActionListener (java.awt.event.ActionListener)6 PropertyChangeListener (java.beans.PropertyChangeListener)6 GroupLayout (javax.swing.GroupLayout)6 ActionEvent (java.awt.event.ActionEvent)5 JScrollPane (javax.swing.JScrollPane)5 Dimension (java.awt.Dimension)4 GridBagConstraints (java.awt.GridBagConstraints)4 GridBagLayout (java.awt.GridBagLayout)4 Insets (java.awt.Insets)4 JCheckBox (javax.swing.JCheckBox)3 JComboBox (javax.swing.JComboBox)3 JSeparator (javax.swing.JSeparator)3