Search in sources :

Example 1 with FocusAdapter

use of java.awt.event.FocusAdapter in project lwjgl by LWJGL.

the class WindowsDisplay method createWindow.

public void createWindow(DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
    this.parent = parent;
    hasParent = parent != null;
    parent_hwnd = parent != null ? getHwnd(parent) : 0;
    this.hwnd = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(), Display.isFullscreen() || isUndecorated(), parent != null, parent_hwnd);
    if (Display.isResizable() && parent == null) {
        setResizable(true);
    }
    if (hwnd == 0) {
        throw new LWJGLException("Failed to create window");
    }
    this.hdc = getDC(hwnd);
    if (hdc == 0) {
        nDestroyWindow(hwnd);
        throw new LWJGLException("Failed to get dc");
    }
    try {
        if (drawable instanceof DrawableGL) {
            int format = WindowsPeerInfo.choosePixelFormat(getHdc(), 0, 0, (PixelFormat) drawable.getPixelFormat(), null, true, true, false, true);
            WindowsPeerInfo.setPixelFormat(getHdc(), format);
        } else {
            peer_info = new WindowsDisplayPeerInfo(true);
            ((DrawableGLES) drawable).initialize(hwnd, hdc, EGL.EGL_WINDOW_BIT, (org.lwjgl.opengles.PixelFormat) drawable.getPixelFormat());
        }
        peer_info.initDC(getHwnd(), getHdc());
        showWindow(getHwnd(), SW_SHOWDEFAULT);
        updateWidthAndHeight();
        if (parent == null) {
            setForegroundWindow(getHwnd());
        } else {
            parent_focused = new AtomicBoolean(false);
            parent.addFocusListener(parent_focus_tracker = new FocusAdapter() {

                public void focusGained(FocusEvent e) {
                    parent_focused.set(true);
                    clearAWTFocus();
                }
            });
            SwingUtilities.invokeLater(new Runnable() {

                public void run() {
                    clearAWTFocus();
                }
            });
        }
        grabFocus();
    } catch (LWJGLException e) {
        nReleaseDC(hwnd, hdc);
        nDestroyWindow(hwnd);
        throw e;
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) FocusAdapter(java.awt.event.FocusAdapter) FocusEvent(java.awt.event.FocusEvent) LWJGLException(org.lwjgl.LWJGLException)

Example 2 with FocusAdapter

use of java.awt.event.FocusAdapter in project pcgen by PCGen.

the class PurchaseModeFrame method initComponents.

private void initComponents() {
    purchaseScoreMinEdit = new JTextField(3);
    purchaseScoreMaxEdit = new JTextField(3);
    statusBar = new JLabel();
    currentPurchaseMethods = new JComboBoxEx();
    currentPurchaseMethods.setAutoSort(true);
    purchaseMethodPointsEdit = new JTextField(4);
    removeMethodButton = new JButton();
    AbstractButton okButton = new JButton();
    okButton.addActionListener(e -> CustomData.writePurchaseModeConfiguration());
    jScrollPane1 = new JScrollPane();
    getContentPane().setLayout(new GridBagLayout());
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    setTitle(PurchaseModeFrame.TITLE);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            exitForm();
        }
    });
    Container jPanel1 = new JPanel();
    jPanel1.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 5));
    JLabel purchaseScoreMinLabel = new JLabel();
    //$NON-NLS-1$
    purchaseScoreMinLabel.setText(LanguageBundle.getString("in_Prefs_purchMin"));
    //$NON-NLS-1$
    purchaseScoreMinLabel.setToolTipText(LanguageBundle.getString("in_Prefs_purchMinTip"));
    purchaseScoreMinLabel.setPreferredSize(new Dimension(140, 15));
    jPanel1.add(purchaseScoreMinLabel);
    purchaseScoreMinEdit.setHorizontalAlignment(SwingConstants.RIGHT);
    purchaseScoreMinEdit.addActionListener(evt -> purchaseScoreMinValueActionPerformed());
    purchaseScoreMinEdit.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            purchaseScoreMinValueActionPerformed();
        }
    });
    jPanel1.add(purchaseScoreMinEdit);
    AbstractButton purchaseScoreMinIncreaseButton = new JButton();
    //$NON-NLS-1$
    purchaseScoreMinIncreaseButton.setText(LanguageBundle.getString("in_Prefs_plus"));
    //$NON-NLS-1$
    purchaseScoreMinIncreaseButton.setToolTipText(LanguageBundle.getString("in_Prefs_incMin"));
    purchaseScoreMinIncreaseButton.addActionListener(evt -> purchaseScoreMinIncreaseButtonActionPerformed());
    jPanel1.add(purchaseScoreMinIncreaseButton);
    AbstractButton purchaseScoreMinDecreaseButton = new JButton();
    //$NON-NLS-1$
    purchaseScoreMinDecreaseButton.setText(LanguageBundle.getString("in_Prefs_minus"));
    //$NON-NLS-1$
    purchaseScoreMinDecreaseButton.setToolTipText(LanguageBundle.getString("in_Prefs_decMin"));
    purchaseScoreMinDecreaseButton.addActionListener(evt -> purchaseScoreMinDecreaseButtonActionPerformed());
    jPanel1.add(purchaseScoreMinDecreaseButton);
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 1.0;
    getContentPane().add(jPanel1, gridBagConstraints);
    Container jPanel2 = new JPanel();
    jPanel2.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 5));
    JLabel purchaseScoreMaxLabel = new JLabel();
    //$NON-NLS-1$
    purchaseScoreMaxLabel.setText(LanguageBundle.getString("in_Prefs_purchMax"));
    //$NON-NLS-1$
    purchaseScoreMaxLabel.setToolTipText(LanguageBundle.getString("in_Prefs_purchMaxTip"));
    purchaseScoreMaxLabel.setPreferredSize(new Dimension(140, 15));
    jPanel2.add(purchaseScoreMaxLabel);
    purchaseScoreMaxEdit.setHorizontalAlignment(SwingConstants.RIGHT);
    purchaseScoreMaxEdit.addActionListener(evt -> purchaseScoreMaxValueActionPerformed());
    purchaseScoreMaxEdit.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            purchaseScoreMaxValueActionPerformed();
        }
    });
    jPanel2.add(purchaseScoreMaxEdit);
    AbstractButton purchaseScoreMaxIncreaseButton = new JButton();
    //$NON-NLS-1$
    purchaseScoreMaxIncreaseButton.setText(LanguageBundle.getString("in_Prefs_plus"));
    //$NON-NLS-1$
    purchaseScoreMaxIncreaseButton.setToolTipText(LanguageBundle.getString("in_Prefs_incMax"));
    purchaseScoreMaxIncreaseButton.addActionListener(evt -> purchaseScoreMaxIncreaseButtonActionPerformed());
    jPanel2.add(purchaseScoreMaxIncreaseButton);
    AbstractButton purchaseScoreMaxDecreaseButton = new JButton();
    //$NON-NLS-1$
    purchaseScoreMaxDecreaseButton.setText(LanguageBundle.getString("in_Prefs_minus"));
    //$NON-NLS-1$
    purchaseScoreMaxDecreaseButton.setToolTipText(LanguageBundle.getString("in_Prefs_decMax"));
    purchaseScoreMaxDecreaseButton.addActionListener(evt -> purchaseScoreMaxDecreaseButtonActionPerformed());
    jPanel2.add(purchaseScoreMaxDecreaseButton);
    GridBagConstraints bagConstraints = new GridBagConstraints();
    bagConstraints.gridx = 0;
    bagConstraints.gridy = 2;
    bagConstraints.fill = GridBagConstraints.HORIZONTAL;
    bagConstraints.anchor = GridBagConstraints.NORTHWEST;
    bagConstraints.weightx = 1.0;
    getContentPane().add(jPanel2, bagConstraints);
    JComponent purchaseMethodPanel = new JPanel();
    purchaseMethodPanel.setLayout(new GridBagLayout());
    purchaseMethodPanel.setBorder(BorderFactory.createTitledBorder(//$NON-NLS-1$
    LanguageBundle.getString("in_Prefs_allowPoints")));
    bagConstraints = new GridBagConstraints();
    bagConstraints.gridx = 0;
    bagConstraints.gridy = 3;
    bagConstraints.fill = GridBagConstraints.HORIZONTAL;
    bagConstraints.anchor = GridBagConstraints.NORTHWEST;
    bagConstraints.weightx = 1.0;
    getContentPane().add(purchaseMethodPanel, bagConstraints);
    Container purchaseMethodNamePanel = new JPanel();
    purchaseMethodNamePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 5));
    JLabel savedMethodLabel = new JLabel();
    //$NON-NLS-1$
    savedMethodLabel.setText(LanguageBundle.getString("in_Prefs_savedMethods"));
    savedMethodLabel.setPreferredSize(new Dimension(140, 15));
    purchaseMethodNamePanel.add(savedMethodLabel);
    purchaseMethodNamePanel.add(currentPurchaseMethods);
    bagConstraints = new GridBagConstraints();
    bagConstraints.gridx = 0;
    bagConstraints.gridy = 0;
    bagConstraints.fill = GridBagConstraints.HORIZONTAL;
    bagConstraints.anchor = GridBagConstraints.NORTHWEST;
    bagConstraints.weightx = 1.0;
    getContentPane().add(purchaseMethodNamePanel, bagConstraints);
    purchaseMethodPanel.add(purchaseMethodNamePanel, bagConstraints);
    Container purchaseMethodPointsPanel = new JPanel();
    purchaseMethodPointsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 5));
    JLabel methodPointsLabel = new JLabel();
    //$NON-NLS-1$
    methodPointsLabel.setText(LanguageBundle.getString("in_Prefs_points"));
    methodPointsLabel.setPreferredSize(new Dimension(140, 15));
    purchaseMethodPointsPanel.add(methodPointsLabel);
    purchaseMethodPointsEdit.setHorizontalAlignment(SwingConstants.RIGHT);
    purchaseMethodPointsEdit.setEditable(false);
    //purchaseMethodPointsEdit.setText("10");
    purchaseMethodPointsPanel.add(purchaseMethodPointsEdit);
    bagConstraints = new GridBagConstraints();
    bagConstraints.gridx = 0;
    bagConstraints.gridy = 1;
    bagConstraints.fill = GridBagConstraints.HORIZONTAL;
    bagConstraints.anchor = GridBagConstraints.NORTHWEST;
    bagConstraints.weightx = 1.0;
    //		getContentPane().add(purchaseMethodPointsPanel, gridBagConstraints);
    purchaseMethodPanel.add(purchaseMethodPointsPanel, bagConstraints);
    currentPurchaseMethods.setPreferredSize(new Dimension(140, 21));
    currentPurchaseMethods.addItemListener(evt -> currentPurchaseMethodsActionPerformed());
    Container purchaseMethodButtonPanel = new JPanel();
    purchaseMethodButtonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    AbstractButton addMethodButton = new JButton();
    //$NON-NLS-1$
    addMethodButton.setText(LanguageBundle.getString("in_Prefs_new"));
    addMethodButton.addActionListener(evt -> addMethodButtonActionPerformed());
    purchaseMethodButtonPanel.add(addMethodButton);
    //$NON-NLS-1$
    removeMethodButton.setText(LanguageBundle.getString("in_Prefs_remove"));
    removeMethodButton.addActionListener(evt -> removeMethodButtonActionPerformed());
    purchaseMethodButtonPanel.add(removeMethodButton);
    bagConstraints = new GridBagConstraints();
    bagConstraints.gridx = 0;
    bagConstraints.gridy = 2;
    bagConstraints.fill = GridBagConstraints.HORIZONTAL;
    bagConstraints.anchor = GridBagConstraints.NORTHWEST;
    bagConstraints.weightx = 1.0;
    purchaseMethodPanel.add(purchaseMethodButtonPanel, bagConstraints);
    //$NON-NLS-1$
    statusBar.setText(LanguageBundle.getString("in_Prefs_setCost"));
    statusBar.setBorder(new BevelBorder(BevelBorder.LOWERED));
    bagConstraints = new GridBagConstraints();
    bagConstraints.gridx = 0;
    bagConstraints.gridy = 6;
    bagConstraints.fill = GridBagConstraints.HORIZONTAL;
    bagConstraints.ipadx = 1;
    bagConstraints.ipady = 1;
    bagConstraints.insets = new Insets(1, 1, 1, 1);
    bagConstraints.anchor = GridBagConstraints.NORTHWEST;
    bagConstraints.weightx = 1.0;
    getContentPane().add(statusBar, bagConstraints);
    Container jPanel3 = new JPanel();
    jPanel3.setLayout(new FlowLayout(FlowLayout.RIGHT));
    //$NON-NLS-1$
    okButton.setText(LanguageBundle.getString("in_Prefs_OK"));
    //$NON-NLS-1$
    okButton.setToolTipText(LanguageBundle.getString("in_Prefs_OKTip"));
    okButton.addActionListener(evt -> okButtonActionPerformed());
    jPanel3.add(okButton);
    AbstractButton resetButton = new JButton();
    //$NON-NLS-1$
    resetButton.setText(LanguageBundle.getString("in_Prefs_Reset"));
    //$NON-NLS-1$
    resetButton.setToolTipText(LanguageBundle.getString("in_Prefs_ResetTip"));
    resetButton.addActionListener(evt -> resetButtonActionPerformed());
    jPanel3.add(resetButton);
    AbstractButton cancelButton = new JButton();
    //$NON-NLS-1$
    cancelButton.setText(LanguageBundle.getString("in_cancel"));
    //$NON-NLS-1$
    cancelButton.setToolTipText(LanguageBundle.getString("in_Prefs_CancelTip"));
    cancelButton.addActionListener(evt -> cancelButtonActionPerformed());
    jPanel3.add(cancelButton);
    /////////////////////////////////////////////////
    bagConstraints = new GridBagConstraints();
    bagConstraints.gridx = 0;
    bagConstraints.gridy = 5;
    bagConstraints.fill = GridBagConstraints.HORIZONTAL;
    bagConstraints.anchor = GridBagConstraints.EAST;
    bagConstraints.weightx = 1.0;
    getContentPane().add(jPanel3, bagConstraints);
    jScrollPane1.setViewportBorder(new BevelBorder(BevelBorder.LOWERED));
    jScrollPane1.setPreferredSize(new Dimension(100, 200));
    purchaseModel = new PurchaseModel();
    renewAbilityScoreCostTable();
    bagConstraints = new GridBagConstraints();
    bagConstraints.gridx = 0;
    bagConstraints.gridy = 0;
    bagConstraints.fill = GridBagConstraints.BOTH;
    bagConstraints.anchor = GridBagConstraints.NORTHWEST;
    bagConstraints.weightx = 1.0;
    bagConstraints.weighty = 1.0;
    getContentPane().add(jScrollPane1, bagConstraints);
    pack();
    initializeCurrentPurchaseMethods();
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) FocusAdapter(java.awt.event.FocusAdapter) GridBagConstraints(java.awt.GridBagConstraints) AbstractButton(javax.swing.AbstractButton) FlowLayout(java.awt.FlowLayout) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) BevelBorder(javax.swing.border.BevelBorder) JButton(javax.swing.JButton) JComponent(javax.swing.JComponent) JLabel(javax.swing.JLabel) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) FocusEvent(java.awt.event.FocusEvent) Container(java.awt.Container) WindowEvent(java.awt.event.WindowEvent) JComboBoxEx(pcgen.gui2.util.JComboBoxEx)

Example 3 with FocusAdapter

use of java.awt.event.FocusAdapter in project intellij-community by JetBrains.

the class EditMavenPropertyDialog method installFocusListeners.

private void installFocusListeners() {
    myNameBox.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            myNameBox.getEditor().selectAll();
        }
    });
    myValueField.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            myValueField.selectAll();
        }
    });
}
Also used : FocusAdapter(java.awt.event.FocusAdapter) FocusEvent(java.awt.event.FocusEvent)

Example 4 with FocusAdapter

use of java.awt.event.FocusAdapter in project intellij-community by JetBrains.

the class SSHCredentialsDialog method createCenterPanel.

protected JComponent createCenterPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    GridBagConstraints gb = new GridBagConstraints();
    // top label.
    gb.insets = JBUI.insets(2);
    gb.weightx = 1;
    gb.weighty = 0;
    gb.gridwidth = 3;
    gb.gridheight = 1;
    gb.gridx = 0;
    gb.gridy = 0;
    gb.anchor = GridBagConstraints.WEST;
    gb.fill = GridBagConstraints.HORIZONTAL;
    JLabel label = new JLabel(SvnBundle.message("label.ssh.authentication.realm", myRealm));
    panel.add(label, gb);
    // user name
    gb.gridy += 1;
    gb.gridwidth = 1;
    gb.weightx = 0;
    gb.fill = GridBagConstraints.NONE;
    label = new JLabel(SvnBundle.message("label.ssh.user.name"));
    panel.add(label, gb);
    // user name field
    gb.gridx = 1;
    gb.gridwidth = 2;
    gb.weightx = 1;
    gb.fill = GridBagConstraints.HORIZONTAL;
    myUserNameText = new JTextField();
    panel.add(myUserNameText, gb);
    label.setLabelFor(myUserNameText);
    if (myUserName != null) {
        myUserNameText.setText(myUserName);
    }
    myUserNameText.selectAll();
    myUserNameText.getDocument().addDocumentListener(this);
    gb.gridy += 1;
    gb.weightx = 0;
    gb.gridx = 0;
    gb.fill = GridBagConstraints.NONE;
    gb.gridwidth = 3;
    // ssh agent type
    mySshAgentButton = new JBRadioButton(SvnBundle.message("radio.ssh.authentication.with.agent"));
    panel.add(mySshAgentButton, gb);
    gb.gridy += 1;
    gb.weightx = 0;
    gb.gridx = 0;
    gb.fill = GridBagConstraints.NONE;
    gb.gridwidth = 3;
    // password type
    myPasswordButton = new JRadioButton(SvnBundle.message("radio.ssh.authentication.with.password"));
    panel.add(myPasswordButton, gb);
    gb.gridy += 1;
    gb.weightx = 0;
    gb.gridx = 0;
    gb.gridwidth = 1;
    gb.fill = GridBagConstraints.NONE;
    gb.gridwidth = 1;
    myPasswordLabel = new JLabel(SvnBundle.message("label.ssh.password"));
    panel.add(myPasswordLabel, gb);
    // passworde field
    gb.gridx = 1;
    gb.weightx = 1;
    gb.gridwidth = 2;
    gb.fill = GridBagConstraints.HORIZONTAL;
    myPasswordText = new JPasswordField();
    panel.add(myPasswordText, gb);
    myPasswordLabel.setLabelFor(myPasswordText);
    gb.gridy += 1;
    gb.weightx = 0;
    gb.gridx = 0;
    gb.fill = GridBagConstraints.NONE;
    gb.gridwidth = 3;
    myKeyButton = new JRadioButton(SvnBundle.message("radio.ssh.authentication.private.key"));
    panel.add(myKeyButton, gb);
    // key file.
    gb.gridy += 1;
    gb.weightx = 0;
    gb.gridx = 0;
    gb.gridwidth = 1;
    gb.fill = GridBagConstraints.NONE;
    gb.gridwidth = 1;
    myKeyFileLabel = new JLabel(SvnBundle.message("label.ssh.key.file"));
    panel.add(myKeyFileLabel, gb);
    // key field
    gb.gridx = 1;
    gb.weightx = 1;
    gb.gridwidth = 2;
    gb.fill = GridBagConstraints.HORIZONTAL;
    myKeyFileText = new TextFieldWithBrowseButton(this);
    myKeyFileText.setEditable(false);
    panel.add(myKeyFileText, gb);
    myKeyFileLabel.setLabelFor(myKeyFileText);
    gb.gridy += 1;
    gb.weightx = 0;
    gb.gridx = 0;
    gb.gridwidth = 1;
    gb.fill = GridBagConstraints.NONE;
    gb.gridwidth = 1;
    myPassphraseLabel = new JLabel(SvnBundle.message("label.ssh.passphrase"));
    panel.add(myPassphraseLabel, gb);
    // key field
    gb.gridx = 1;
    gb.weightx = 1;
    gb.gridwidth = 2;
    gb.fill = GridBagConstraints.HORIZONTAL;
    myPassphraseText = new JPasswordField(30);
    panel.add(myPassphraseText, gb);
    myPassphraseText.getDocument().addDocumentListener(this);
    myPassphraseText.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            checkKeyFile();
            updateOKButton();
        }
    });
    myPassphraseLabel.setLabelFor(myPassphraseText);
    // key file.
    gb.gridy += 1;
    gb.weightx = 0;
    gb.gridx = 0;
    gb.gridwidth = 1;
    gb.fill = GridBagConstraints.NONE;
    gb.gridwidth = 1;
    myPortLabel = new JLabel(SvnBundle.message("label.ssh.port"));
    panel.add(myPortLabel, gb);
    // key field
    gb.gridx = 1;
    gb.weightx = 0;
    gb.gridwidth = 2;
    gb.fill = GridBagConstraints.NONE;
    myPortField = new JTextField();
    myPortField.setColumns(6);
    panel.add(myPortField, gb);
    myPortLabel.setLabelFor(myPortField);
    myPortField.setText("22");
    myPortField.setMinimumSize(myPortField.getPreferredSize());
    myPortField.getDocument().addDocumentListener(this);
    ButtonGroup group = new ButtonGroup();
    group.add(mySshAgentButton);
    group.add(myPasswordButton);
    group.add(myKeyButton);
    mySshAgentButton.setEnabled(myIsAgentAllowed);
    group.setSelected((myIsAgentAllowed ? mySshAgentButton : myPasswordButton).getModel(), true);
    gb.gridy += 1;
    gb.gridx = 0;
    gb.gridwidth = 3;
    gb.weightx = 1;
    gb.anchor = GridBagConstraints.WEST;
    gb.fill = GridBagConstraints.HORIZONTAL;
    myAllowSaveCheckBox = new JCheckBox(SvnBundle.message("checkbox.ssh.keep.for.current.session"));
    panel.add(myAllowSaveCheckBox, gb);
    if (!myAllowSave) {
        gb.gridy += 1;
        final JLabel cannotSaveLabel = new JLabel(SvnBundle.message("svn.cannot.save.credentials.store-auth-creds"));
        cannotSaveLabel.setForeground(UIUtil.getInactiveTextColor());
        panel.add(cannotSaveLabel, gb);
    }
    gb.gridy += 1;
    panel.add(new JSeparator(), gb);
    gb.gridy += 1;
    gb.weighty = 1;
    panel.add(new JLabel(), gb);
    myAllowSaveCheckBox.setSelected(false);
    myAllowSaveCheckBox.setEnabled(myAllowSave);
    mySshAgentButton.addActionListener(this);
    myKeyButton.addActionListener(this);
    myPasswordButton.addActionListener(this);
    updateFields();
    updateOKButton();
    return panel;
}
Also used : FocusAdapter(java.awt.event.FocusAdapter) JBRadioButton(com.intellij.ui.components.JBRadioButton) FocusEvent(java.awt.event.FocusEvent) TextFieldWithBrowseButton(com.intellij.openapi.ui.TextFieldWithBrowseButton)

Example 5 with FocusAdapter

use of java.awt.event.FocusAdapter in project EnrichmentMapApp by BaderLab.

the class SliderBarPanel method getTextField.

public JFormattedTextField getTextField() {
    if (textField == null) {
        textField = new JFormattedTextField(format) {

            @Override
            public Dimension getPreferredSize() {
                final Dimension d = super.getPreferredSize();
                if (this.getGraphics() != null) {
                    // Set the preferred text field size after it gets a Graphics
                    int sw = 16 + this.getGraphics().getFontMetrics().stringWidth(format.format(max));
                    d.width = Math.max(sw, 48);
                }
                return d;
            }
        };
        textField.setHorizontalAlignment(JTextField.RIGHT);
        textField.addActionListener(evt -> {
            textFieldValueChanged();
        });
        textField.addFocusListener(new FocusAdapter() {

            @Override
            public void focusLost(FocusEvent e) {
                textFieldValueChanged();
            }
        });
    }
    return textField;
}
Also used : FocusAdapter(java.awt.event.FocusAdapter) JFormattedTextField(javax.swing.JFormattedTextField) Dimension(java.awt.Dimension) FocusEvent(java.awt.event.FocusEvent)

Aggregations

FocusAdapter (java.awt.event.FocusAdapter)26 FocusEvent (java.awt.event.FocusEvent)26 Dimension (java.awt.Dimension)6 KeyAdapter (java.awt.event.KeyAdapter)5 KeyEvent (java.awt.event.KeyEvent)5 JLabel (javax.swing.JLabel)5 JTextField (javax.swing.JTextField)5 FocusListener (java.awt.event.FocusListener)3 JButton (javax.swing.JButton)3 Container (java.awt.Container)2 FlowLayout (java.awt.FlowLayout)2 MouseAdapter (java.awt.event.MouseAdapter)2 MouseEvent (java.awt.event.MouseEvent)2 JComponent (javax.swing.JComponent)2 JPanel (javax.swing.JPanel)2 JPasswordField (javax.swing.JPasswordField)2 JScrollPane (javax.swing.JScrollPane)2 Border (javax.swing.border.Border)2 DocumentEvent (javax.swing.event.DocumentEvent)2 DocumentListener (javax.swing.event.DocumentListener)2