Changeset 12657


Ignore:
Timestamp:
2006-09-04T11:40:48+12:00 (18 years ago)
Author:
kjdon
Message:

pressing Enter in the text field now closes the prompt

File:
1 edited

Legend:

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

    r12119 r12657  
    3737public class RenamePrompt
    3838    extends JDialog
    39     implements ActionListener
     39    implements ActionListener, KeyListener
    4040{
    4141    private JButton cancel_button;
     
    6666    }
    6767
     68    public void keyPressed(KeyEvent e) {
     69    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
     70            // Enter: Click the button in focus
     71            Object source = e.getSource();
     72            if (source instanceof AbstractButton) {
     73                ((AbstractButton) source).doClick();
     74            } else if (source == name_textfield) {
     75        ok_button.doClick();
     76        }
     77        }
     78    }
     79
     80    public void keyReleased(KeyEvent e) { }
     81   
     82    public void keyTyped(KeyEvent e) { }
     83
    6884
    6985    public String display()
     
    84100    cancel_button.addActionListener(this);
    85101    ok_button.addActionListener(this);
     102    ok_button.addKeyListener(this);
     103    name_textfield.addKeyListener(this);
    86104
    87105    // Layout
Note: See TracChangeset for help on using the changeset viewer.