Changeset 5185


Ignore:
Timestamp:
2003-08-19T13:29:36+12:00 (21 years ago)
Author:
mdewsnip
Message:

Now responds to enter key.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/WarningDialog.java

    r5164 r5185  
    1414public class WarningDialog
    1515    extends JDialog
    16     implements ActionListener {
     16    implements ActionListener, KeyListener {
    1717
    1818    static final private Dimension LABEL_SIZE = new Dimension(150, 25);
     
    9090    ok_button.addActionListener(this);
    9191    cancel_button.addActionListener(this);
     92    ok_button.addKeyListener(this);
     93    cancel_button.addKeyListener(this);
    9294    // Layout
    9395    icon_label.setBorder(BorderFactory.createEmptyBorder(0,0,0,5));
     
    171173    }
    172174
     175
     176    /** Gives notification of key events on the buttons */
     177    public void keyPressed(KeyEvent e) {
     178    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
     179        // Enter: Click the button in focus
     180        Object source = e.getSource();
     181        if (source instanceof AbstractButton) {
     182        ((AbstractButton) source).doClick();
     183        }
     184    }
     185    }
     186
     187    public void keyReleased(KeyEvent e) { }
     188
     189    public void keyTyped(KeyEvent e) { }
     190
     191
    173192    public int display() {
    174193    ///ystem.err.println("Show " + full_property + ": " + Gatherer.config.get(full_property, false));
Note: See TracChangeset for help on using the changeset viewer.