Search in sources :

Example 11 with FocusEvent

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

the class Find method jbInit.

/**
	 *	Static Init.
	 *  <pre>
	 *  tabbedPane
	 *      simplePanel
	 *          scontentPanel
	 *          confirmPanelS
	 *      advancedPanel
	 *          toolBar
	 *          GC
	 *          confirmPanelA
	 *  southPanel
	 *      statusBar
	 *  </pre>
	 *  @throws Exception
	 */
private void jbInit() throws Exception {
    spaceE = Box.createHorizontalStrut(8);
    spaceN = Box.createVerticalStrut(8);
    spaceW = Box.createHorizontalStrut(8);
    spaceS = Box.createVerticalStrut(8);
    bIgnore.setIcon(new ImageIcon(org.compiere.Adempiere.class.getResource("images/Ignore24.gif")));
    bIgnore.setMargin(new Insets(2, 2, 2, 2));
    bIgnore.setToolTipText(Msg.getMsg(Env.getCtx(), "Ignore"));
    bIgnore.addActionListener(this);
    fQueryName.setToolTipText(m_sToolTipText);
    fQueryName.setEditable(true);
    fQueryName.addActionListener(this);
    fQueryName.getEditor().getEditorComponent().addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent arg0) {
            // fQueryName received the focus - delete the tip text so the user can type without 
            // having to delete the tip.
            int index = fQueryName.getSelectedIndex();
            if (index < 0) {
                if (fQueryName.getSelectedItem() == null || fQueryName.getSelectedItem().equals(m_sTipText)) {
                    fQueryName.setSelectedIndex(-1);
                    fQueryName.setSelectedItem("");
                }
            }
        }

        public void focusLost(FocusEvent arg0) {
            // fQueryName lost the focus. If the field is blank, replace the tip text.
            if (fQueryName.getSelectedItem() != null && fQueryName.getSelectedItem().equals("")) {
                fQueryName.setSelectedItem(m_sTipText);
            }
        }
    });
    bSave.setIcon(new ImageIcon(org.compiere.Adempiere.class.getResource("images/Save24.gif")));
    bSave.setMargin(new Insets(2, 2, 2, 2));
    bSave.setToolTipText(Msg.getMsg(Env.getCtx(), "Save"));
    bSave.addActionListener(this);
    bNew.setIcon(new ImageIcon(org.compiere.Adempiere.class.getResource("images/New24.gif")));
    bNew.setMargin(new Insets(2, 2, 2, 2));
    bNew.setToolTipText(Msg.getMsg(Env.getCtx(), "New"));
    bNew.addActionListener(this);
    bDelete.setIcon(new ImageIcon(org.compiere.Adempiere.class.getResource("images/Delete24.gif")));
    bDelete.setMargin(new Insets(2, 2, 2, 2));
    bDelete.setToolTipText(Msg.getMsg(Env.getCtx(), "Delete"));
    bDelete.addActionListener(this);
    //
    southPanel.setLayout(southLayout);
    valueLabel.setLabelFor(valueField);
    valueLabel.setText(Msg.translate(Env.getCtx(), "Value"));
    nameLabel.setLabelFor(nameField);
    nameLabel.setText(Msg.translate(Env.getCtx(), "Name"));
    descriptionLabel.setLabelFor(descriptionField);
    descriptionLabel.setText(Msg.translate(Env.getCtx(), "Description"));
    valueField.setText("%");
    valueField.setColumns(FIELDLENGTH);
    nameField.setText("%");
    nameField.setColumns(FIELDLENGTH);
    descriptionField.setText("%");
    descriptionField.setColumns(FIELDLENGTH);
    scontentPanel.setToolTipText(Msg.getMsg(Env.getCtx(), "FindTip"));
    docNoLabel.setLabelFor(docNoField);
    docNoLabel.setText(Msg.translate(Env.getCtx(), "DocumentNo"));
    docNoField.setText("%");
    docNoField.setColumns(FIELDLENGTH);
    advancedScrollPane.setPreferredSize(new Dimension(540, 410));
    southPanel.add(statusBar, BorderLayout.SOUTH);
    this.getContentPane().add(southPanel, BorderLayout.SOUTH);
    //
    scontentPanel.setLayout(scontentLayout);
    simplePanel.setLayout(simpleLayout);
    simplePanel.add(confirmPanelS, BorderLayout.SOUTH);
    simplePanel.add(scontentPanel, BorderLayout.CENTER);
    scontentPanel.add(valueLabel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(7, 5, 0, 5), 0, 0));
    scontentPanel.add(nameLabel, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(7, 5, 0, 5), 0, 0));
    scontentPanel.add(descriptionLabel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(7, 5, 5, 5), 0, 0));
    scontentPanel.add(valueField, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0));
    scontentPanel.add(descriptionField, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
    scontentPanel.add(docNoLabel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(7, 5, 0, 5), 0, 0));
    scontentPanel.add(nameField, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0));
    scontentPanel.add(docNoField, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 5), 0, 0));
    //
    scontentPanel.add(spaceE, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
    scontentPanel.add(spaceN, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
    scontentPanel.add(spaceW, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
    scontentPanel.add(spaceS, new GridBagConstraints(2, 15, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0));
    //
    //	tabbedPane.add(simplePanel, Msg.getMsg(Env.getCtx(),"Find"));
    tabbedPane.add(simplePanel, Msg.getMsg(Env.getCtx(), "Find"));
    //
    toolBar.add(bIgnore, null);
    toolBar.addSeparator();
    toolBar.add(bNew, null);
    toolBar.add(bDelete, null);
    toolBar.add(fQueryName, null);
    toolBar.add(bSave, null);
    advancedPanel.setLayout(advancedLayout);
    advancedPanel.add(toolBar, BorderLayout.NORTH);
    advancedPanel.add(confirmPanelA, BorderLayout.SOUTH);
    advancedPanel.add(advancedScrollPane, BorderLayout.CENTER);
    advancedScrollPane.getViewport().add(advancedTable, null);
    //	tabbedPane.add(advancedPanel, Msg.getMsg(Env.getCtx(),"Advanced"));
    tabbedPane.add(advancedPanel, Msg.getMsg(Env.getCtx(), "Advanced"));
    //
    this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
    //
    confirmPanelA.addActionListener(this);
    confirmPanelS.addActionListener(this);
    //
    JButton b = ConfirmPanel.createNewButton(true);
    confirmPanelS.addComponent(b);
    b.addActionListener(this);
    // teo_sarca, [ 1670847 ] Find dialog: closing and canceling need same functionality
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            cmd_cancel();
        }
    });
}
Also used : ImageIcon(javax.swing.ImageIcon) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) WindowEvent(java.awt.event.WindowEvent) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) FocusListener(java.awt.event.FocusListener) FocusEvent(java.awt.event.FocusEvent)

Example 12 with FocusEvent

use of java.awt.event.FocusEvent in project aerospike-client-java by aerospike.

the class GuiDisplay method initialize.

/**
	 * Initialize the contents of the frame.
	 */
private void initialize() {
    frmAerospikeExamples = new JFrame();
    frmAerospikeExamples.setTitle("Aerospike Java Client Examples");
    frmAerospikeExamples.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frmAerospikeExamples.pack();
    frmAerospikeExamples.getContentPane().setLayout(new BorderLayout(0, 0));
    splitPane = new JSplitPane();
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    frmAerospikeExamples.getContentPane().add(splitPane, BorderLayout.CENTER);
    mainPanel = new JPanel();
    splitPane.setLeftComponent(mainPanel);
    mainPanel.setLayout(new BorderLayout(0, 0));
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    runButton = new JButton("Run");
    runButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent ev) {
            consoleTextArea.setText("");
            run_selected_examples();
        }
    });
    buttonPanel.add(runButton);
    mainPanel.add(buttonPanel, BorderLayout.SOUTH);
    exitButton = new JButton("Quit");
    exitButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent arg0) {
            Container Frame = exitButton.getParent();
            do {
                Frame = Frame.getParent();
            } while (!(Frame instanceof JFrame));
            ((JFrame) Frame).dispose();
        }
    });
    buttonPanel.add(exitButton);
    sourceTextPane = new JTextArea();
    sourceTextPane.setTabSize(2);
    sourceTextPane.setEditable(false);
    scrollPane = new JScrollPane(sourceTextPane);
    scrollPane.setViewportBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    scrollPane.setPreferredSize(new Dimension(600, 100));
    mainPanel.add(scrollPane, BorderLayout.CENTER);
    connectionPanel = new JPanel();
    connectionPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    lblServerHost = new JLabel("Server Host");
    connectionPanel.add(lblServerHost);
    seedHostTextField = new JTextField();
    seedHostTextField.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            params.host = seedHostTextField.getText();
        }
    });
    connectionPanel.add(seedHostTextField);
    seedHostTextField.setColumns(10);
    lblPort = new JLabel("Port");
    connectionPanel.add(lblPort);
    portTextField = new JTextField();
    portTextField.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent arg0) {
            String newValue = namespaceTextField.getText();
            if (newValue != null && newValue != "") {
                try {
                    params.port = Integer.parseInt(newValue);
                } catch (NumberFormatException ne) {
                //ne.printStackTrace();
                }
            }
        }
    });
    connectionPanel.add(portTextField);
    portTextField.setColumns(4);
    lblusername = new JLabel("User");
    connectionPanel.add(lblusername);
    usernameTextField = new JTextField();
    usernameTextField.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            params.user = usernameTextField.getText();
        }
    });
    connectionPanel.add(usernameTextField);
    usernameTextField.setColumns(8);
    lblpassword = new JLabel("Password");
    connectionPanel.add(lblpassword);
    passwordTextField = new JPasswordField();
    passwordTextField.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            params.user = new String(passwordTextField.getPassword());
        }
    });
    connectionPanel.add(passwordTextField);
    passwordTextField.setColumns(8);
    lblnameSpace = new JLabel("Namespace");
    connectionPanel.add(lblnameSpace);
    namespaceTextField = new JTextField();
    namespaceTextField.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            params.namespace = namespaceTextField.getText();
        }
    });
    connectionPanel.add(namespaceTextField);
    namespaceTextField.setColumns(8);
    lblSet = new JLabel("Set");
    connectionPanel.add(lblSet);
    txtSetTextfield = new JTextField();
    txtSetTextfield.addKeyListener(new KeyAdapter() {

        @Override
        public void keyTyped(KeyEvent e) {
            params.set = txtSetTextfield.getText();
        }
    });
    connectionPanel.add(txtSetTextfield);
    txtSetTextfield.setColumns(8);
    mainPanel.add(connectionPanel, BorderLayout.NORTH);
    examplePanel = new JPanel();
    examplePanel.setLayout(new BoxLayout(examplePanel, BoxLayout.Y_AXIS));
    exampleScrollPane = new JScrollPane(examplePanel);
    mainPanel.add(exampleScrollPane, BorderLayout.WEST);
    // init values
    seedHostTextField.setText(params.host);
    portTextField.setText(Integer.toString(params.port));
    namespaceTextField.setText(params.namespace);
    txtSetTextfield.setText(params.set);
    //int width = 785;
    int width = 1000;
    int height = 180;
    consoleTextArea = new JTextArea();
    consoleTextArea.setSize(new Dimension(width, height));
    consoleTextArea.setEditable(false);
    consoleScrollPane = new JScrollPane(consoleTextArea);
    consoleScrollPane.setPreferredSize(new Dimension(width, height));
    consoleScrollPane.setSize(new Dimension(width, height));
    splitPane.setRightComponent(consoleScrollPane);
    buttonGroup = new ButtonGroup();
    JRadioButton jrb;
    for (String example : Main.getAllExampleNames()) {
        jrb = new JRadioButton(example);
        jrb.setActionCommand(example);
        jrb.addActionListener(this);
        buttonGroup.add(jrb);
        examplePanel.add(jrb);
    }
    frmAerospikeExamples.pack();
}
Also used : JPanel(javax.swing.JPanel) FocusAdapter(java.awt.event.FocusAdapter) FlowLayout(java.awt.FlowLayout) JTextArea(javax.swing.JTextArea) JRadioButton(javax.swing.JRadioButton) KeyAdapter(java.awt.event.KeyAdapter) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) FocusEvent(java.awt.event.FocusEvent) KeyEvent(java.awt.event.KeyEvent) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) JScrollPane(javax.swing.JScrollPane) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) EtchedBorder(javax.swing.border.EtchedBorder) JPasswordField(javax.swing.JPasswordField) ButtonGroup(javax.swing.ButtonGroup) JSplitPane(javax.swing.JSplitPane)

Example 13 with FocusEvent

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

the class TrailingSpacesStripperTest method testModifyAndAltTabAway.

public void testModifyAndAltTabAway() throws IOException {
    configureFromFileText("x.txt", "xxx<caret>\nyyy");
    type(' ');
    FocusEvent event = new FocusEvent(getEditor().getContentComponent(), 1005);
    FocusListener[] listeners = getEditor().getContentComponent().getListeners(FocusListener.class);
    for (FocusListener listener : listeners) {
        listener.focusLost(event);
    }
    stripTrailingSpaces();
    checkResultByText("xxx <caret>\nyyy");
}
Also used : FocusEvent(java.awt.event.FocusEvent) FocusListener(java.awt.event.FocusListener)

Example 14 with FocusEvent

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

the class DarculaComboBoxUI method createEditor.

@Override
protected ComboBoxEditor createEditor() {
    final ComboBoxEditor comboBoxEditor = super.createEditor();
    Component editor = comboBoxEditor == null ? null : comboBoxEditor.getEditorComponent();
    if (editor instanceof JComponent) {
        ((JComponent) editor).setBorder(JBUI.Borders.empty());
    }
    if (editor != null) {
        editor.addKeyListener(new KeyAdapter() {

            @Override
            public void keyPressed(KeyEvent e) {
                process(e);
            }

            private void process(KeyEvent e) {
                final int code = e.getKeyCode();
                if ((code == KeyEvent.VK_UP || code == KeyEvent.VK_DOWN) && e.getModifiers() == 0) {
                    comboBox.dispatchEvent(e);
                }
            }

            @Override
            public void keyReleased(KeyEvent e) {
                process(e);
            }
        });
        editor.addFocusListener(new FocusAdapter() {

            @Override
            public void focusGained(FocusEvent e) {
                update();
            }

            void update() {
                if (comboBox != null) {
                    comboBox.revalidate();
                    comboBox.repaint();
                }
            }

            @Override
            public void focusLost(FocusEvent e) {
                update();
            }
        });
    }
    return comboBoxEditor;
}
Also used : KeyEvent(java.awt.event.KeyEvent) FocusAdapter(java.awt.event.FocusAdapter) KeyAdapter(java.awt.event.KeyAdapter) FocusEvent(java.awt.event.FocusEvent)

Example 15 with FocusEvent

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

the class MacIntelliJComboBoxUI method createEditor.

@Override
protected ComboBoxEditor createEditor() {
    final ComboBoxEditor comboBoxEditor = new BasicComboBoxEditor.UIResource() {

        @Override
        protected JTextField createEditorComponent() {
            return new JTextField() {

                {
                    setOpaque(false);
                    setBorder(ourDefaultEditorBorder);
                }

                @Override
                public Color getBackground() {
                    if (!isEnabled()) {
                        return Gray.xF8;
                    }
                    return super.getBackground();
                }

                public void setText(String s) {
                    if (getText().equals(s)) {
                        return;
                    }
                    super.setText(s);
                }

                @Override
                public void setBorder(Border border) {
                }

                @Override
                public Border getBorder() {
                    return ourDefaultEditorBorder;
                }

                @Override
                public Dimension getPreferredSize() {
                    Dimension size = super.getPreferredSize();
                    return new Dimension(size.width, DEFAULT_ICON.getIconHeight() - 6);
                }
            };
        }
    };
    if (comboBoxEditor.getEditorComponent() != null) {
        comboBoxEditor.getEditorComponent().addKeyListener(new KeyAdapter() {

            @Override
            public void keyPressed(KeyEvent e) {
                process(e);
            }

            @Override
            public void keyReleased(KeyEvent e) {
                process(e);
            }

            private void process(KeyEvent e) {
                final int code = e.getKeyCode();
                if ((code == KeyEvent.VK_UP || code == KeyEvent.VK_DOWN) && e.getModifiers() == 0) {
                    comboBox.dispatchEvent(e);
                }
            }
        });
        comboBoxEditor.getEditorComponent().addFocusListener(new FocusAdapter() {

            @Override
            public void focusGained(FocusEvent e) {
                update();
            }

            @Override
            public void focusLost(FocusEvent e) {
                update();
            }

            void update() {
                if (comboBox != null) {
                    comboBox.revalidate();
                    comboBox.repaint();
                }
            }
        });
    }
    return comboBoxEditor;
}
Also used : KeyEvent(java.awt.event.KeyEvent) FocusAdapter(java.awt.event.FocusAdapter) KeyAdapter(java.awt.event.KeyAdapter) Border(javax.swing.border.Border) FocusEvent(java.awt.event.FocusEvent)

Aggregations

FocusEvent (java.awt.event.FocusEvent)68 FocusListener (java.awt.event.FocusListener)32 FocusAdapter (java.awt.event.FocusAdapter)26 ActionEvent (java.awt.event.ActionEvent)15 ActionListener (java.awt.event.ActionListener)14 JLabel (javax.swing.JLabel)12 Dimension (java.awt.Dimension)8 KeyEvent (java.awt.event.KeyEvent)8 JButton (javax.swing.JButton)8 JPanel (javax.swing.JPanel)8 JTextField (javax.swing.JTextField)8 Border (javax.swing.border.Border)8 UIResource (javax.swing.plaf.UIResource)6 GridBagConstraints (java.awt.GridBagConstraints)5 GridBagLayout (java.awt.GridBagLayout)5 Insets (java.awt.Insets)5 KeyAdapter (java.awt.event.KeyAdapter)5 MouseEvent (java.awt.event.MouseEvent)5 JComboBox (javax.swing.JComboBox)5 Component (java.awt.Component)4