Search in sources :

Example 51 with FocusEvent

use of java.awt.event.FocusEvent 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 52 with FocusEvent

use of java.awt.event.FocusEvent in project ACS by ACS-Community.

the class ScriptFilter method getGroupTextField.

/**
	 * This method initializes groupTextField
	 * @return javax.swing.JTextField
	 */
private JTextField getGroupTextField() {
    if (groupTextField == null) {
        Dimension d = new Dimension(150, 19);
        groupTextField = new JTextField();
        groupTextField.setPreferredSize(d);
        //groupTextField.setSize(d);
        groupTextField.setMinimumSize(d);
        groupTextField.setToolTipText("Sampling Group where to add the new Sample. Only alphanumeric and underscore characters.");
        groupTextField.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
        groupTextField.setHorizontalAlignment(JTextField.LEFT);
        groupTextField.setText("SampGroup");
        groupTextField.addFocusListener(new FocusListener() {

            public void focusGained(FocusEvent e) {
            // Do nothing special :)
            }

            public void focusLost(FocusEvent e) {
                if (!groupTextField.getText().matches("^([a-z]|[A-Z]|[0-9]|_)+$")) {
                    JOptionPane.showConfirmDialog(SamplingSystemGUI.this, "Group name '" + groupTextField.getText() + "' is invalid.\nPlease use only alphanumeric characters and/or underscores.", "Invalid group name", JOptionPane.PLAIN_MESSAGE, JOptionPane.WARNING_MESSAGE);
                    groupTextField.setText("");
                    groupTextField.grabFocus();
                }
            }
        });
    }
    return groupTextField;
}
Also used : Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) FocusListener(java.awt.event.FocusListener) FocusEvent(java.awt.event.FocusEvent)

Example 53 with FocusEvent

use of java.awt.event.FocusEvent in project ACS by ACS-Community.

the class TabPanel method validateAfterProgrammaticUpdate.

/**
	 * When the status or content of a Gui component has been modified programmatically,
	 * this method must be called to ensure the new contents are written through to the
	 * model.
	 * 
	 * @param trg a gui component that was programmatically updated
	 */
public void validateAfterProgrammaticUpdate(JComponent trg) {
    FocusEvent evt = new FocusEvent(trg, FocusEvent.FOCUS_LOST);
    FocusListener[] lis = trg.getFocusListeners();
    for (int i = 0; i < lis.length; i++) {
        lis[i].focusLost(evt);
    }
}
Also used : FocusEvent(java.awt.event.FocusEvent) FocusListener(java.awt.event.FocusListener)

Example 54 with FocusEvent

use of java.awt.event.FocusEvent 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 55 with FocusEvent

use of java.awt.event.FocusEvent in project adempiere by adempiere.

the class WindowMenu method createImageBox.

private JXTitledPanel createImageBox(JPanel p, JDialog dialog, int width, int height, CFrame window) {
    BufferedImage bi = new BufferedImage(window.getWidth(), window.getHeight(), //	TYPE_INT_ARGB is tinted red
    BufferedImage.TYPE_INT_RGB);
    window.paintAll(bi.createGraphics());
    Image image = bi.getScaledInstance(width, height, Image.SCALE_SMOOTH);
    final JXTitledPanel box = new JXTitledPanel();
    final Painter painter = box.getTitlePainter();
    box.setTitlePainter(null);
    box.setFocusable(true);
    box.setTitle(window.getTitle());
    final JXImageView imageView = new JXImageView();
    imageView.setImage(image);
    imageView.setEditable(false);
    box.setContentContainer(imageView);
    box.setPreferredSize(new Dimension(width, height));
    box.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    box.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent e) {
            box.requestFocus();
        }
    });
    imageView.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent e) {
            box.requestFocus();
        }
    });
    PreviewMouseAdapter adapter = new PreviewMouseAdapter(dialog, window);
    box.addMouseListener(adapter);
    imageView.addMouseListener(adapter);
    imageView.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    box.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            box.setTitlePainter(painter);
        }

        @Override
        public void focusLost(FocusEvent e) {
            box.setTitlePainter(null);
        }
    });
    return box;
}
Also used : JXTitledPanel(org.jdesktop.swingx.JXTitledPanel) FocusAdapter(java.awt.event.FocusAdapter) MouseEvent(java.awt.event.MouseEvent) JXImageView(org.jdesktop.swingx.JXImageView) Painter(org.jdesktop.swingx.painter.Painter) MouseAdapter(java.awt.event.MouseAdapter) Dimension(java.awt.Dimension) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage) FocusEvent(java.awt.event.FocusEvent) BufferedImage(java.awt.image.BufferedImage)

Aggregations

FocusEvent (java.awt.event.FocusEvent)81 FocusListener (java.awt.event.FocusListener)38 FocusAdapter (java.awt.event.FocusAdapter)33 JLabel (javax.swing.JLabel)21 ActionEvent (java.awt.event.ActionEvent)18 ActionListener (java.awt.event.ActionListener)17 JPanel (javax.swing.JPanel)15 JTextField (javax.swing.JTextField)15 Dimension (java.awt.Dimension)14 JButton (javax.swing.JButton)10 KeyEvent (java.awt.event.KeyEvent)9 JCheckBox (javax.swing.JCheckBox)9 BoxLayout (javax.swing.BoxLayout)8 JComboBox (javax.swing.JComboBox)8 Border (javax.swing.border.Border)8 Component (java.awt.Component)7 GridBagConstraints (java.awt.GridBagConstraints)6 GridBagLayout (java.awt.GridBagLayout)6 Insets (java.awt.Insets)6 MouseEvent (java.awt.event.MouseEvent)6