Search in sources :

Example 81 with FocusListener

use of java.awt.event.FocusListener in project Botnak by Gocnak.

the class BaseComboBoxUI method installListeners.

protected void installListeners() {
    super.installListeners();
    propertyChangeListener = new PropertyChangeHandler();
    comboBox.addPropertyChangeListener(propertyChangeListener);
    if (AbstractLookAndFeel.getTheme().doShowFocusFrame()) {
        focusListener = new FocusListener() {

            public void focusGained(FocusEvent e) {
                if (comboBox != null) {
                    orgBorder = comboBox.getBorder();
                    orgBackgroundColor = comboBox.getBackground();
                    LookAndFeel laf = UIManager.getLookAndFeel();
                    if (laf instanceof AbstractLookAndFeel) {
                        if (orgBorder instanceof UIResource) {
                            Border focusBorder = ((AbstractLookAndFeel) laf).getBorderFactory().getFocusFrameBorder();
                            comboBox.setBorder(focusBorder);
                        }
                        Color backgroundColor = AbstractLookAndFeel.getTheme().getFocusBackgroundColor();
                        comboBox.setBackground(backgroundColor);
                    }
                }
            }

            public void focusLost(FocusEvent e) {
                if (comboBox != null) {
                    if (orgBorder instanceof UIResource) {
                        comboBox.setBorder(orgBorder);
                    }
                    comboBox.setBackground(orgBackgroundColor);
                }
            }
        };
        comboBox.addFocusListener(focusListener);
    }
}
Also used : FocusListener(java.awt.event.FocusListener) FocusEvent(java.awt.event.FocusEvent) Border(javax.swing.border.Border) UIResource(javax.swing.plaf.UIResource)

Example 82 with FocusListener

use of java.awt.event.FocusListener in project Botnak by Gocnak.

the class BaseEditorPaneUI method installListeners.

protected void installListeners() {
    super.installListeners();
    if (AbstractLookAndFeel.getTheme().doShowFocusFrame()) {
        focusListener = new FocusListener() {

            public void focusGained(FocusEvent e) {
                if (getComponent() != null) {
                    orgBorder = getComponent().getBorder();
                    LookAndFeel laf = UIManager.getLookAndFeel();
                    if (laf instanceof AbstractLookAndFeel && orgBorder instanceof UIResource) {
                        Border focusBorder = ((AbstractLookAndFeel) laf).getBorderFactory().getFocusFrameBorder();
                        getComponent().setBorder(focusBorder);
                    }
                    getComponent().invalidate();
                    getComponent().repaint();
                }
            }

            public void focusLost(FocusEvent e) {
                if (getComponent() != null) {
                    if (orgBorder instanceof UIResource) {
                        getComponent().setBorder(orgBorder);
                    }
                    getComponent().invalidate();
                    getComponent().repaint();
                }
            }
        };
        getComponent().addFocusListener(focusListener);
    }
}
Also used : FocusListener(java.awt.event.FocusListener) FocusEvent(java.awt.event.FocusEvent) Border(javax.swing.border.Border) UIResource(javax.swing.plaf.UIResource)

Example 83 with FocusListener

use of java.awt.event.FocusListener in project Botnak by Gocnak.

the class BasePasswordFieldUI method installListeners.

protected void installListeners() {
    super.installListeners();
    if (AbstractLookAndFeel.getTheme().doShowFocusFrame()) {
        focusListener = new FocusListener() {

            public void focusGained(FocusEvent e) {
                if (getComponent() != null) {
                    orgBorder = getComponent().getBorder();
                    LookAndFeel laf = UIManager.getLookAndFeel();
                    if (laf instanceof AbstractLookAndFeel && orgBorder instanceof UIResource) {
                        Border focusBorder = ((AbstractLookAndFeel) laf).getBorderFactory().getFocusFrameBorder();
                        getComponent().setBorder(focusBorder);
                    }
                    getComponent().invalidate();
                    getComponent().repaint();
                }
            }

            public void focusLost(FocusEvent e) {
                if (getComponent() != null) {
                    if (orgBorder instanceof UIResource) {
                        getComponent().setBorder(orgBorder);
                    }
                    getComponent().invalidate();
                    getComponent().repaint();
                }
            }
        };
        getComponent().addFocusListener(focusListener);
    }
}
Also used : FocusListener(java.awt.event.FocusListener) FocusEvent(java.awt.event.FocusEvent) Border(javax.swing.border.Border) UIResource(javax.swing.plaf.UIResource)

Example 84 with FocusListener

use of java.awt.event.FocusListener in project Botnak by Gocnak.

the class BaseTextFieldUI method installListeners.

protected void installListeners() {
    super.installListeners();
    if (AbstractLookAndFeel.getTheme().doShowFocusFrame()) {
        focusListener = new FocusListener() {

            public void focusGained(FocusEvent e) {
                if (getComponent() != null) {
                    orgBorder = getComponent().getBorder();
                    LookAndFeel laf = UIManager.getLookAndFeel();
                    if (laf instanceof AbstractLookAndFeel && orgBorder instanceof UIResource) {
                        Border focusBorder = ((AbstractLookAndFeel) laf).getBorderFactory().getFocusFrameBorder();
                        getComponent().setBorder(focusBorder);
                    }
                    getComponent().invalidate();
                    getComponent().repaint();
                }
            }

            public void focusLost(FocusEvent e) {
                if (getComponent() != null) {
                    if (orgBorder instanceof UIResource) {
                        getComponent().setBorder(orgBorder);
                    }
                    getComponent().invalidate();
                    getComponent().repaint();
                }
            }
        };
        getComponent().addFocusListener(focusListener);
    }
}
Also used : FocusListener(java.awt.event.FocusListener) FocusEvent(java.awt.event.FocusEvent) Border(javax.swing.border.Border) UIResource(javax.swing.plaf.UIResource)

Example 85 with FocusListener

use of java.awt.event.FocusListener in project ceylon-compiler by ceylon.

the class SelectToolTask method createPane.

JOptionPane createPane(final Properties props) {
    JPanel body = new JPanel(new GridBagLayout());
    GridBagConstraints lc = new GridBagConstraints();
    lc.insets.right = 10;
    lc.insets.bottom = 3;
    GridBagConstraints fc = new GridBagConstraints();
    fc.anchor = GridBagConstraints.WEST;
    fc.gridx = 1;
    fc.gridwidth = GridBagConstraints.REMAINDER;
    fc.insets.bottom = 3;
    JLabel toolLabel = new JLabel("Tool:");
    body.add(toolLabel, lc);
    String[] toolChoices = { "apt", "javac", "javadoc", "javah", "javap" };
    if (true || toolProperty == null) {
        // include empty value in setup mode
        List<String> l = new ArrayList<String>(Arrays.asList(toolChoices));
        l.add(0, "");
        toolChoices = l.toArray(new String[l.size()]);
    }
    toolChoice = new JComboBox(toolChoices);
    if (toolName != null)
        toolChoice.setSelectedItem(toolName);
    toolChoice.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            String tn = (String) e.getItem();
            argsField.setText(getDefaultArgsForTool(props, tn));
            if (toolProperty != null)
                okButton.setEnabled(!tn.equals(""));
        }
    });
    body.add(toolChoice, fc);
    argsField = new JTextField(getDefaultArgsForTool(props, toolName), 40);
    if (toolProperty == null || argsProperty != null) {
        JLabel argsLabel = new JLabel("Args:");
        body.add(argsLabel, lc);
        body.add(argsField, fc);
        argsField.addFocusListener(new FocusListener() {

            public void focusGained(FocusEvent e) {
            }

            public void focusLost(FocusEvent e) {
                String toolName = (String) toolChoice.getSelectedItem();
                if (toolName.length() > 0)
                    props.put(toolName + ".args", argsField.getText());
            }
        });
    }
    defaultCheck = new JCheckBox("Set as default");
    if (toolProperty == null)
        defaultCheck.setSelected(true);
    else
        body.add(defaultCheck, fc);
    final JOptionPane p = new JOptionPane(body);
    okButton = new JButton("OK");
    okButton.setEnabled(toolProperty == null || (toolName != null && !toolName.equals("")));
    okButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JDialog d = (JDialog) SwingUtilities.getAncestorOfClass(JDialog.class, p);
            d.setVisible(false);
        }
    });
    p.setOptions(new Object[] { okButton });
    return p;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) ItemEvent(java.awt.event.ItemEvent) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) FocusEvent(java.awt.event.FocusEvent) JOptionPane(javax.swing.JOptionPane) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) ItemListener(java.awt.event.ItemListener) FocusListener(java.awt.event.FocusListener) JDialog(javax.swing.JDialog)

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