Search in sources :

Example 51 with KeyListener

use of java.awt.event.KeyListener in project com.revolsys.open by revolsys.

the class MouseOverlay method keyTyped.

@Override
public void keyTyped(final KeyEvent e) {
    for (final Component overlay : getOverlays()) {
        if (overlay instanceof KeyListener) {
            final KeyListener listener = (KeyListener) overlay;
            listener.keyTyped(e);
            if (e.isConsumed()) {
                return;
            }
        }
    }
}
Also used : KeyListener(java.awt.event.KeyListener) JComponent(javax.swing.JComponent) Component(java.awt.Component)

Example 52 with KeyListener

use of java.awt.event.KeyListener in project SeqMonk by s-andrews.

the class SmoothingQuantitation method getOptionsPanel.

/* (non-Javadoc)
	 * @see uk.ac.babraham.SeqMonk.Quantitation.Quantitation#getOptionsPanel(uk.ac.babraham.SeqMonk.SeqMonkApplication)
	 */
public JPanel getOptionsPanel() {
    if (optionPanel != null) {
        // We've done this already
        return optionPanel;
    }
    optionPanel = new JPanel();
    optionPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.weightx = 0.5;
    gbc.weighty = 0.1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    optionPanel.add(new JLabel("Smoothing method"), gbc);
    gbc.gridx = 2;
    correctionActions = new JComboBox(new String[] { "Adjacent Probes", "Window Size" });
    optionPanel.add(correctionActions, gbc);
    gbc.gridx = 1;
    gbc.gridy++;
    optionPanel.add(new JLabel("Size"), gbc);
    distanceField = new JTextField("" + distance);
    distanceField.addKeyListener(new NumberKeyListener(false, false));
    distanceField.addKeyListener(new KeyListener() {

        public void keyTyped(KeyEvent arg0) {
        }

        public void keyReleased(KeyEvent arg0) {
            optionsChanged();
        }

        public void keyPressed(KeyEvent arg0) {
        }
    });
    gbc.gridx++;
    optionPanel.add(distanceField, gbc);
    return optionPanel;
}
Also used : KeyEvent(java.awt.event.KeyEvent) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) KeyListener(java.awt.event.KeyListener) NumberKeyListener(uk.ac.babraham.SeqMonk.Utilities.NumberKeyListener) JTextField(javax.swing.JTextField) NumberKeyListener(uk.ac.babraham.SeqMonk.Utilities.NumberKeyListener)

Example 53 with KeyListener

use of java.awt.event.KeyListener in project JFramework by gugumall.

the class BeanGen method init.

/**
 */
private void init() {
    this.gui.connect.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            connect();
        }
    });
    this.gui.choose.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            choosePath();
        }
    });
    this.gui.gen.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            gen();
        }
    });
    this.gui.showTables.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            showTable();
        }
    });
    this.gui.db.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
        }

        public void keyReleased(KeyEvent e) {
            if (gui.dbms.getSelectedIndex() == 0) {
                return;
            }
            String dbms = gui.dbms.getSelectedItem().toString();
            String url = BeanGen.DBMS_URL_PATTERN.get(dbms).toString();
            url = url.replaceAll("HOST", gui.host.getText().trim());
            url = url.replaceAll("DATABASE", gui.db.getText().trim());
            gui.info.setText(url);
        }

        public void keyTyped(KeyEvent e) {
        }
    });
    this.gui.host.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
        }

        public void keyReleased(KeyEvent e) {
            if (gui.dbms.getSelectedIndex() == 0) {
                return;
            }
            String dbms = gui.dbms.getSelectedItem().toString();
            String url = BeanGen.DBMS_URL_PATTERN.get(dbms).toString();
            url = url.replaceAll("HOST", gui.host.getText().trim());
            url = url.replaceAll("DATABASE", gui.db.getText().trim());
            gui.info.setText(url);
        }

        public void keyTyped(KeyEvent e) {
        }
    });
}
Also used : KeyEvent(java.awt.event.KeyEvent) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) KeyListener(java.awt.event.KeyListener)

Example 54 with KeyListener

use of java.awt.event.KeyListener in project abstools by abstools.

the class TextArea method undo.

/**
 * Undoes the last action, if any has been performed.
 */
public void undo() {
    try {
        if (undoManager.canUndo()) {
            undoManager.undo();
            for (KeyListener kl : getKeyListeners()) {
                kl.keyTyped(null);
                kl.keyReleased(null);
            }
        }
    } catch (CannotUndoException e) {
    }
}
Also used : CannotUndoException(javax.swing.undo.CannotUndoException) KeyListener(java.awt.event.KeyListener)

Example 55 with KeyListener

use of java.awt.event.KeyListener in project abstools by abstools.

the class TextArea method redo.

/**
 * Redoes the last action, if any has been performed.
 */
public void redo() {
    try {
        if (undoManager.canRedo()) {
            undoManager.redo();
            for (KeyListener kl : getKeyListeners()) {
                kl.keyTyped(null);
                kl.keyReleased(null);
            }
        }
    } catch (CannotRedoException e) {
    }
}
Also used : CannotRedoException(javax.swing.undo.CannotRedoException) KeyListener(java.awt.event.KeyListener)

Aggregations

KeyListener (java.awt.event.KeyListener)64 KeyEvent (java.awt.event.KeyEvent)53 JPanel (javax.swing.JPanel)20 ActionEvent (java.awt.event.ActionEvent)18 ActionListener (java.awt.event.ActionListener)17 GridBagConstraints (java.awt.GridBagConstraints)15 JLabel (javax.swing.JLabel)14 JTextField (javax.swing.JTextField)13 GridBagLayout (java.awt.GridBagLayout)12 Insets (java.awt.Insets)11 BorderLayout (java.awt.BorderLayout)8 Dimension (java.awt.Dimension)8 FocusEvent (java.awt.event.FocusEvent)8 FocusListener (java.awt.event.FocusListener)8 JButton (javax.swing.JButton)8 Point (java.awt.Point)7 MouseAdapter (java.awt.event.MouseAdapter)6 MouseEvent (java.awt.event.MouseEvent)6 JComponent (javax.swing.JComponent)5 Color (java.awt.Color)4