Results 1 to 3 of 3
  1. #1
    vsmilejay is offline Member
    Join Date
    Aug 2010
    Rep Power

    Post Creating shortcutkey for jbutton

    I want to know how to create short key for jbutton without using mnemonics
    and i`ve used this code

    KeyboardFocusManager.getCurrentKeyboardFocusManage r()
    .addKeyEventDispatcher(new KeyEventDispatcher() {
    public boolean dispatchKeyEvent(KeyEvent e) {

    int c=e.getKeyCode();
    return false;




    This code works,but if i press f2 for two time two MessageDialog Box are show .
    I want to know how to set f2 for display only one MessageDialog ...

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

  3. #3
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power


    how to set f2 for display only one MessageDialog
    Have a boolean flag that you test and set that would control the display of the message.
    First time it's true and you set it false and display the message.
    The second time it's false and you just return.

Similar Threads

  1. JButton Help
    By ravjot28 in forum AWT / Swing
    Replies: 2
    Last Post: 01-17-2010, 02:07 PM
  2. how to give JButton a name when creating GridLayout
    By yasmin k in forum AWT / Swing
    Replies: 5
    Last Post: 11-04-2009, 12:16 AM
  3. Creating files stopped creating...
    By Dieter in forum Advanced Java
    Replies: 3
    Last Post: 09-26-2009, 12:45 AM
  4. Creating a JButton that does not show focus
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-26-2008, 08:38 PM
  5. Help with JButton
    By geoffreybarwise in forum New To Java
    Replies: 4
    Last Post: 05-21-2008, 11:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts