Search in sources :

Example 6 with FocusListener

use of java.awt.event.FocusListener in project jgnash by ccavanaugh.

the class SellSharePanel method registerListeners.

private void registerListeners() {
    FocusListener focusListener = new FocusAdapter() {

        @Override
        public void focusLost(final FocusEvent evt) {
            updateTotalField();
        }
    };
    feePanel.addFocusListener(focusListener);
    feePanel.addActionListener(this);
    gainsPanel.addActionListener(this);
    quantityField.addFocusListener(focusListener);
    priceField.addFocusListener(focusListener);
    datePanel.getDateField().addKeyListener(keyListener);
    feePanel.addKeyListener(keyListener);
    memoField.addKeyListener(keyListener);
    priceField.addKeyListener(keyListener);
    quantityField.addKeyListener(keyListener);
    securityCombo.addKeyListener(keyListener);
    getReconcileCheckBox().addKeyListener(keyListener);
}
Also used : FocusAdapter(java.awt.event.FocusAdapter) FocusListener(java.awt.event.FocusListener) FocusEvent(java.awt.event.FocusEvent)

Example 7 with FocusListener

use of java.awt.event.FocusListener in project JMRI by JMRI.

the class AbstractStreamConnectionConfig method checkInitDone.

@SuppressWarnings("unchecked")
@Override
protected void checkInitDone() {
    if (log.isDebugEnabled()) {
        log.debug("init called for " + name());
    }
    if (init) {
        return;
    }
    if (adapter.getSystemConnectionMemo() != null) {
        systemPrefixField.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (!adapter.getSystemConnectionMemo().setSystemPrefix(systemPrefixField.getText())) {
                    JOptionPane.showMessageDialog(null, "System Prefix " + systemPrefixField.getText() + " is already assigned");
                    systemPrefixField.setText(adapter.getSystemConnectionMemo().getSystemPrefix());
                }
            }
        });
        systemPrefixField.addFocusListener(new FocusListener() {

            @Override
            public void focusLost(FocusEvent e) {
                if (!adapter.getSystemConnectionMemo().setSystemPrefix(systemPrefixField.getText())) {
                    JOptionPane.showMessageDialog(null, "System Prefix " + systemPrefixField.getText() + " is already assigned");
                    systemPrefixField.setText(adapter.getSystemConnectionMemo().getSystemPrefix());
                }
            }

            @Override
            public void focusGained(FocusEvent e) {
            }
        });
        connectionNameField.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (!adapter.getSystemConnectionMemo().setUserName(connectionNameField.getText())) {
                    JOptionPane.showMessageDialog(null, "Connection Name " + connectionNameField.getText() + " is already assigned");
                    connectionNameField.setText(adapter.getSystemConnectionMemo().getUserName());
                }
            }
        });
        connectionNameField.addFocusListener(new FocusListener() {

            @Override
            public void focusLost(FocusEvent e) {
                if (!adapter.getSystemConnectionMemo().setUserName(connectionNameField.getText())) {
                    JOptionPane.showMessageDialog(null, "Connection Name " + connectionNameField.getText() + " is already assigned");
                    connectionNameField.setText(adapter.getSystemConnectionMemo().getUserName());
                }
            }

            @Override
            public void focusGained(FocusEvent e) {
            }
        });
        for (String i : options.keySet()) {
            final String item = i;
            if (options.get(i).getComponent() instanceof JComboBox) {
                ((JComboBox<?>) options.get(i).getComponent()).addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        adapter.setOptionState(item, options.get(item).getItem());
                    }
                });
            }
        }
    }
    init = true;
}
Also used : ActionListener(java.awt.event.ActionListener) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) FocusListener(java.awt.event.FocusListener) FocusEvent(java.awt.event.FocusEvent)

Example 8 with FocusListener

use of java.awt.event.FocusListener in project JMRI by JMRI.

the class AddSignalMastPanel method updateDCCMastPanel.

void updateDCCMastPanel() {
    if ((!Bundle.getMessage("DCCMast").equals(signalMastDriver.getSelectedItem())) && (!Bundle.getMessage("LNCPMast").equals(signalMastDriver.getSelectedItem()))) {
        return;
    }
    dccAspect = new HashMap<String, DCCAspectPanel>(10);
    java.util.List<jmri.CommandStation> connList = jmri.InstanceManager.getList(jmri.CommandStation.class);
    systemPrefixBox.removeAllItems();
    if (!connList.isEmpty()) {
        for (int x = 0; x < connList.size(); x++) {
            jmri.CommandStation station = connList.get(x);
            if (Bundle.getMessage("LNCPMast").equals(signalMastDriver.getSelectedItem())) {
                if (station instanceof jmri.jmrix.loconet.SlotManager) {
                    systemPrefixBox.addItem(station.getUserName());
                }
            } else {
                systemPrefixBox.addItem(station.getUserName());
            }
        }
    } else {
        systemPrefixBox.addItem("None");
    }
    String mastType = mastNames.get(mastBox.getSelectedIndex()).getName();
    mastType = mastType.substring(11, mastType.indexOf(".xml"));
    jmri.implementation.DefaultSignalAppearanceMap sigMap = jmri.implementation.DefaultSignalAppearanceMap.getMap(sigsysname, mastType);
    java.util.Enumeration<String> aspects = sigMap.getAspects();
    SignalSystem sigsys = InstanceManager.getDefault(jmri.SignalSystemManager.class).getSystem(sigsysname);
    while (aspects.hasMoreElements()) {
        String aspect = aspects.nextElement();
        DCCAspectPanel aPanel = new DCCAspectPanel(aspect);
        dccAspect.put(aspect, aPanel);
        aPanel.setAspectId((String) sigsys.getProperty(aspect, "dccAspect"));
    }
    dccMastPanel.removeAll();
    dccMastPanel.setLayout(new jmri.util.javaworld.GridLayout2(dccAspect.size() + 3, 2));
    dccMastPanel.add(systemPrefixBoxLabel);
    dccMastPanel.add(systemPrefixBox);
    dccMastPanel.add(dccAspectAddressLabel);
    dccMastPanel.add(dccAspectAddressField);
    if (dccAddressListener == null) {
        dccAddressListener = new FocusListener() {

            @Override
            public void focusLost(FocusEvent e) {
                if (dccAspectAddressField.getText().equals("")) {
                    return;
                }
                validateDCCAddress();
            }

            @Override
            public void focusGained(FocusEvent e) {
            }
        };
        dccAspectAddressField.addFocusListener(dccAddressListener);
    }
    if (mast == null) {
        systemPrefixBoxLabel.setEnabled(true);
        systemPrefixBox.setEnabled(true);
        dccAspectAddressLabel.setEnabled(true);
        dccAspectAddressField.setEnabled(true);
    }
    for (String aspect : dccAspect.keySet()) {
        // load aspect panels from hashmap
        dccMastPanel.add(dccAspect.get(aspect).getPanel());
    }
    if ((dccAspect.size() & 1) == 1) {
        // spacer
        dccMastPanel.add(new JLabel());
    }
    dccMastPanel.add(new JLabel(Bundle.getMessage("DCCMastCopyAspectId") + ":"));
    dccMastPanel.add(copyFromMastSelection());
}
Also used : JLabel(javax.swing.JLabel) FocusEvent(java.awt.event.FocusEvent) SignalSystemManager(jmri.SignalSystemManager) SignalSystem(jmri.SignalSystem) FocusListener(java.awt.event.FocusListener)

Example 9 with FocusListener

use of java.awt.event.FocusListener in project JMRI by JMRI.

the class JsonNetworkConnectionConfig method checkInitDone.

@Override
protected void checkInitDone() {
    super.checkInitDone();
    //options.put(Bundle.getMessage("DiscoveredServices"), new Option(Bundle.getMessage("DiscoveredServices"), services, false));
    if (this.adapter.getSystemConnectionMemo() != null) {
        final JsonClientSystemConnectionMemo memo = (JsonClientSystemConnectionMemo) this.adapter.getSystemConnectionMemo();
        this.transmitPrefixField.setText(memo.getTransmitPrefix());
        this.transmitPrefixField.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                memo.setTransmitPrefix(transmitPrefixField.getText());
                transmitPrefixField.setText(memo.getTransmitPrefix());
            }
        });
        this.transmitPrefixField.addFocusListener(new FocusListener() {

            @Override
            public void focusLost(FocusEvent e) {
                memo.setTransmitPrefix(transmitPrefixField.getText());
                transmitPrefixField.setText(memo.getTransmitPrefix());
            }

            @Override
            public void focusGained(FocusEvent e) {
            // nothing to do
            }
        });
        this.nodeIdentityField.setText(memo.getNodeIdentity());
        this.nodeIdentityField.setToolTipText(Bundle.getMessage("NodeIdentityToolTip"));
    }
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) FocusListener(java.awt.event.FocusListener) FocusEvent(java.awt.event.FocusEvent)

Example 10 with FocusListener

use of java.awt.event.FocusListener in project JMRI by JMRI.

the class AddSignalMastPanel method dccUnLitPanel.

void dccUnLitPanel() {
    dccUnLitPanel.setLayout(new BoxLayout(dccUnLitPanel, BoxLayout.Y_AXIS));
    JPanel dccDetails = new JPanel();
    dccDetails.add(new JLabel(Bundle.getMessage("DCCMastSetAspectId") + ":"));
    dccDetails.add(unLitAspectField);
    unLitAspectField.setText("31");
    dccUnLitPanel.add(dccDetails);
    TitledBorder border = BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black));
    border.setTitle(Bundle.getMessage("DCCUnlitAspectNumber"));
    dccUnLitPanel.setBorder(border);
    unLitAspectField.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
            if (unLitAspectField.getText().equals("")) {
                return;
            }
            if (!validateAspectId(unLitAspectField.getText())) {
                unLitAspectField.requestFocusInWindow();
            }
        }

        @Override
        public void focusGained(FocusEvent e) {
        }
    });
}
Also used : JPanel(javax.swing.JPanel) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) TitledBorder(javax.swing.border.TitledBorder) FocusListener(java.awt.event.FocusListener) FocusEvent(java.awt.event.FocusEvent)

Aggregations

FocusListener (java.awt.event.FocusListener)87 FocusEvent (java.awt.event.FocusEvent)80 ActionEvent (java.awt.event.ActionEvent)24 ActionListener (java.awt.event.ActionListener)23 JLabel (javax.swing.JLabel)20 JTextField (javax.swing.JTextField)17 Dimension (java.awt.Dimension)16 JPanel (javax.swing.JPanel)16 JButton (javax.swing.JButton)15 KeyEvent (java.awt.event.KeyEvent)12 JComboBox (javax.swing.JComboBox)11 BorderLayout (java.awt.BorderLayout)9 Component (java.awt.Component)9 MouseEvent (java.awt.event.MouseEvent)9 KeyListener (java.awt.event.KeyListener)8 JCheckBox (javax.swing.JCheckBox)8 ChangeListener (javax.swing.event.ChangeListener)8 Color (java.awt.Color)7 GridBagConstraints (java.awt.GridBagConstraints)7 MouseAdapter (java.awt.event.MouseAdapter)7