Results 1 to 6 of 6
  1. #1
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default [SOLVED] JOptionPane KeyEvent

    Hi, here again :), I was able to set Default button by:
    Java Code:
        this.getRootPane().setDefaultButton(cmdExit);


    When user click EXIT button a JOptionPane will show asking if user really want to exit.
    When user click "YES" then the program will be terminated, if "NO" then back to LOGIN FORM.
    Everything works expectedly when I use MOUSE events.
    On KeyPress event when OptionPane show and press TAB then to set its focus on "YES" button then press enter the command for "NO" event executes.

    I missing something in KEYPRESS event?


    Thanks in advance,
    geje
    Last edited by mine0926; 05-05-2010 at 03:09 AM.

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,233
    Rep Power
    6

  3. #3
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default

    thanks,

    I will post back for the results.

  4. #4
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default

    I try space button and it works expectedly. But when I use Enter key to fire the event of the selected button ("YES") it still fire the event for "NO" button.

  5. #5
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,233
    Rep Power
    6

    Default

    If you need more help post your SSCCE demonstrating the problem.

  6. #6
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default

    camickr,
    I just misread the link you gave me ("Enter and Button").

    Thanks,
    geje

Similar Threads

  1. Help with JOptionPane
    By sanctishit in forum New To Java
    Replies: 1
    Last Post: 03-10-2010, 10:20 AM
  2. need help with a JOptionPane
    By dr4g0nk1ng in forum Advanced Java
    Replies: 2
    Last Post: 02-19-2010, 09:40 PM
  3. need help for JOptionPane....
    By keycoffee in forum New To Java
    Replies: 1
    Last Post: 02-09-2010, 08:59 AM
  4. Replies: 11
    Last Post: 12-25-2009, 10:30 PM
  5. Replies: 0
    Last Post: 08-17-2009, 03:59 PM

Posting Permissions

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