Search in sources :

Example 11 with FocusAdapter

use of java.awt.event.FocusAdapter in project gephi by gephi.

the class DirectoryChooserUI method createBottomPanel.

private void createBottomPanel(JFileChooser fc) {
    bottomPanel = new JPanel();
    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.LINE_AXIS));
    JPanel labelPanel = new JPanel();
    labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.PAGE_AXIS));
    labelPanel.add(Box.createRigidArea(verticalStrut1));
    JLabel fnl = new JLabel(fileNameLabelText);
    fnl.setDisplayedMnemonic(fileNameLabelMnemonic);
    fnl.setAlignmentY(0);
    labelPanel.add(fnl);
    labelPanel.add(Box.createRigidArea(new Dimension(1, 12)));
    JLabel ftl = new JLabel(filesOfTypeLabelText);
    ftl.setDisplayedMnemonic(filesOfTypeLabelMnemonic);
    labelPanel.add(ftl);
    bottomPanel.add(labelPanel);
    bottomPanel.add(Box.createRigidArea(new Dimension(15, 0)));
    JPanel fileAndFilterPanel = new JPanel();
    fileAndFilterPanel.add(Box.createRigidArea(verticalStrut3));
    fileAndFilterPanel.setLayout(new BoxLayout(fileAndFilterPanel, BoxLayout.Y_AXIS));
    filenameTextField = new JTextField(24) {

        @Override
        public Dimension getMaximumSize() {
            return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height);
        }
    };
    filenameTextField.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent e) {
            updateCompletions();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            updateCompletions();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
        }
    });
    filenameTextField.addKeyListener(new TextFieldKeyListener());
    fnl.setLabelFor(filenameTextField);
    filenameTextField.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            if (!getFileChooser().isMultiSelectionEnabled()) {
                tree.clearSelection();
            }
        }
    });
    // disable TAB focus transfer, we need it for completion
    Set<AWTKeyStroke> tKeys = filenameTextField.getFocusTraversalKeys(java.awt.KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
    Set<AWTKeyStroke> newTKeys = new HashSet<AWTKeyStroke>(tKeys);
    newTKeys.remove(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, 0));
    // #107305: enable at least Ctrl+TAB if we have TAB for completion
    newTKeys.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, KeyEvent.CTRL_DOWN_MASK));
    filenameTextField.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, newTKeys);
    fileAndFilterPanel.add(filenameTextField);
    fileAndFilterPanel.add(Box.createRigidArea(verticalStrut3));
    filterTypeComboBoxModel = createFilterComboBoxModel();
    fc.addPropertyChangeListener(filterTypeComboBoxModel);
    filterTypeComboBox = new JComboBox(filterTypeComboBoxModel);
    ftl.setLabelFor(filterTypeComboBox);
    filterTypeComboBox.setRenderer(createFilterComboBoxRenderer());
    fileAndFilterPanel.add(filterTypeComboBox);
    bottomPanel.add(fileAndFilterPanel);
    bottomPanel.add(Box.createRigidArea(horizontalStrut1));
    createButtonsPanel(fc);
}
Also used : DocumentListener(javax.swing.event.DocumentListener) FocusAdapter(java.awt.event.FocusAdapter) DocumentEvent(javax.swing.event.DocumentEvent) FocusEvent(java.awt.event.FocusEvent)

Example 12 with FocusAdapter

use of java.awt.event.FocusAdapter in project antlrworks by antlr.

the class DialogTestTemplate method initComponents.

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - RP Talusan
    dialogPane = new JPanel();
    contentPanel = new JPanel();
    textTestRadio = new JRadioButton();
    scrollPane1 = new JScrollPane();
    testTextArea = new JTextPane();
    classTestRadio = new JRadioButton();
    testClassField = new JTextField();
    buttonBar = new JPanel();
    okButton = new JButton();
    cancelButton = new JButton();
    testClassHiddenField = new JTextField();
    CellConstraints cc = new CellConstraints();
    //======== this ========
    String title = "Edit Test Rig";
    if (qualifiedFileName != null && !"".equals(qualifiedFileName))
        title = "Edit " + XJUtils.getLastPathComponent(qualifiedFileName) + " Test Rig";
    if (grammarLanguage != null && !"".equals(grammarLanguage))
        title += " for " + grammarLanguage;
    setTitle(title);
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    //======== dialogPane ========
    {
        dialogPane.setBorder(Borders.DIALOG_BORDER);
        dialogPane.setMinimumSize(new Dimension(340, 250));
        dialogPane.setLayout(new BorderLayout());
        //======== contentPanel ========
        {
            contentPanel.setLayout(new FormLayout(new ColumnSpec[] { new ColumnSpec(ColumnSpec.RIGHT, Sizes.DEFAULT, FormSpec.NO_GROW), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW) }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.LINE_GAP_ROWSPEC, new RowSpec(RowSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW), FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC }));
            //---- textTestRadio ----
            textTestRadio.setText("Text:");
            contentPanel.add(textTestRadio, cc.xy(1, 1));
            //======== scrollPane1 ========
            {
                scrollPane1.setPreferredSize(new Dimension(300, 200));
                scrollPane1.setViewportView(testTextArea);
            }
            contentPanel.add(scrollPane1, cc.xywh(3, 1, 3, 5));
            //---- classTestRadio ----
            classTestRadio.setText("Class:");
            contentPanel.add(classTestRadio, cc.xy(1, 7));
            //---- testClassField ----
            testClassField.addFocusListener(new FocusAdapter() {

                @Override
                public void focusGained(FocusEvent e) {
                    if (TEXT_FULLY_QUALIFIED_CLASS_NAME.equals(testClassField.getText())) {
                        testClassField.setForeground(Color.BLACK);
                        testClassField.setText("");
                    }
                }

                @Override
                public void focusLost(FocusEvent e) {
                    testClassHiddenField.setText(testClassField.getText());
                    if ("".equals(testClassField.getText())) {
                        testClassField.setForeground(Color.LIGHT_GRAY);
                        testClassField.setText(TEXT_FULLY_QUALIFIED_CLASS_NAME);
                    }
                }
            });
            contentPanel.add(testClassField, cc.xywh(3, 7, 3, 1));
        }
        dialogPane.add(contentPanel, BorderLayout.CENTER);
        //======== buttonBar ========
        {
            buttonBar.setBorder(Borders.BUTTON_BAR_GAP_BORDER);
            buttonBar.setLayout(new FormLayout(new ColumnSpec[] { FormFactory.GLUE_COLSPEC, FormFactory.BUTTON_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, FormFactory.BUTTON_COLSPEC }, RowSpec.decodeSpecs("pref")));
            //---- okButton ----
            okButton.setText("OK");
            buttonBar.add(okButton, cc.xy(2, 1));
            //---- cancelButton ----
            cancelButton.setText("Cancel");
            buttonBar.add(cancelButton, cc.xy(4, 1));
        }
        dialogPane.add(buttonBar, BorderLayout.SOUTH);
    }
    contentPane.add(dialogPane, BorderLayout.CENTER);
    setSize(625, 395);
    //---- buttonGroup1 ----
    ButtonGroup buttonGroup1 = new ButtonGroup();
    buttonGroup1.add(textTestRadio);
    buttonGroup1.add(classTestRadio);
// JFormDesigner - End of component initialization  //GEN-END:initComponents
}
Also used : FocusAdapter(java.awt.event.FocusAdapter) FocusEvent(java.awt.event.FocusEvent)

Example 13 with FocusAdapter

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

the class ExtractMethodDialog method createParametersPanel.

protected void createParametersPanel() {
    if (myParamTable != null) {
        myCenterPanel.remove(myParamTable);
    }
    myParamTable = createParameterTableComponent();
    myParamTable.setMinimumSize(JBUI.size(500, 100));
    myCenterPanel.add(myParamTable, BorderLayout.CENTER);
    final JTable table = UIUtil.findComponentOfType(myParamTable, JTable.class);
    myCenterPanel.add(SeparatorFactory.createSeparator("&Parameters", table), BorderLayout.NORTH);
    if (table != null) {
        table.addFocusListener(new FocusAdapter() {

            @Override
            public void focusGained(FocusEvent e) {
                if (table.getRowCount() > 0) {
                    final int col = table.getSelectedColumn();
                    final int row = table.getSelectedRow();
                    if (col == -1 || row == -1) {
                        table.getSelectionModel().setSelectionInterval(0, 0);
                        table.getColumnModel().getSelectionModel().setSelectionInterval(0, 0);
                    }
                }
            }
        });
    }
}
Also used : FocusAdapter(java.awt.event.FocusAdapter) FocusEvent(java.awt.event.FocusEvent)

Example 14 with FocusAdapter

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

the class FileTemplateConfigurable method createComponent.

@Override
public JComponent createComponent() {
    myMainPanel = new JPanel(new GridBagLayout());
    myNameField = new JTextField();
    myExtensionField = new JTextField();
    mySplitter = new Splitter(true, myProportion);
    myAdjustBox = new JCheckBox(IdeBundle.message("checkbox.reformat.according.to.style"));
    myLiveTemplateBox = new JCheckBox(IdeBundle.message("checkbox.enable.live.templates"));
    myTemplateEditor = createEditor();
    myDescriptionComponent = new JEditorPane(UIUtil.HTML_MIME, EMPTY_HTML);
    myDescriptionComponent.setEditable(false);
    myDescriptionComponent.addHyperlinkListener(new BrowserHyperlinkListener());
    myTopPanel = new JPanel(new GridBagLayout());
    JPanel descriptionPanel = new JPanel(new GridBagLayout());
    descriptionPanel.add(SeparatorFactory.createSeparator(IdeBundle.message("label.description"), null), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, JBUI.insetsBottom(2), 0, 0));
    descriptionPanel.add(ScrollPaneFactory.createScrollPane(myDescriptionComponent), new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, JBUI.insetsTop(2), 0, 0));
    myMainPanel.add(myTopPanel, new GridBagConstraints(0, 0, 4, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, JBUI.emptyInsets(), 0, 0));
    myMainPanel.add(mySplitter, new GridBagConstraints(0, 2, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, JBUI.emptyInsets(), 0, 0));
    mySplitter.setSecondComponent(descriptionPanel);
    setShowInternalMessage(null);
    myNameField.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(@NotNull FocusEvent e) {
            onNameChanged();
        }
    });
    myExtensionField.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(@NotNull FocusEvent e) {
            onNameChanged();
        }
    });
    myMainPanel.setPreferredSize(JBUI.size(400, 300));
    return myMainPanel;
}
Also used : FocusAdapter(java.awt.event.FocusAdapter) Splitter(com.intellij.openapi.ui.Splitter) BrowserHyperlinkListener(com.intellij.ui.BrowserHyperlinkListener) FocusEvent(java.awt.event.FocusEvent)

Example 15 with FocusAdapter

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

the class ChangeSignatureDialogBase method createSignaturePanel.

private JComponent createSignaturePanel() {
    mySignatureArea = createSignaturePreviewComponent();
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(SeparatorFactory.createSeparator(RefactoringBundle.message("signature.preview.border.title"), null), BorderLayout.NORTH);
    panel.add(mySignatureArea, BorderLayout.CENTER);
    mySignatureArea.setPreferredSize(new Dimension(-1, 130));
    mySignatureArea.setMinimumSize(new Dimension(-1, 130));
    mySignatureArea.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            Container root = findTraversalRoot(getContentPane());
            if (root != null) {
                Component c = root.getFocusTraversalPolicy().getComponentAfter(root, mySignatureArea);
                if (c != null) {
                    IdeFocusManager.findInstance().requestFocus(c, true);
                }
            }
        }
    });
    updateSignature();
    return panel;
}
Also used : FocusAdapter(java.awt.event.FocusAdapter) 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