Results 1 to 3 of 3
  1. #1
    Valkyrie is offline Member
    Join Date
    Oct 2009
    Rep Power

    Default Checking if a button was pressed in a Window.

    I have created an input dialog window that has an OK button to submit information and a cancel button to close the dialog window. I want to know, how do I add an event to the cancel button so when its clicked it goes to one of my if statements that I have in my program?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    There are several ways to solve this. One way is to give the class that holds the buttons a return value field as well as a getter method. After the dialog returns, query the getter method. I sometimes do this and use an int and borrow the constants from JOptionPane.

  3. #3
    syntrax is offline Member
    Join Date
    Sep 2009
    Rep Power


    wow, without a working sample is very hard to explain how to do it. I can tell you how to do it, but that wouldn't be much of help.

Similar Threads

  1. Replies: 6
    Last Post: 11-22-2010, 12:55 PM
  2. change url in parent window from child window
    By rakesh_n_mehta in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 07-09-2009, 12:17 PM
  3. get key pressed
    By prashant in forum Networking
    Replies: 1
    Last Post: 03-26-2009, 10:10 PM
  4. Waiting for a button to be pressed
    By SomeGuyOverThere in forum New To Java
    Replies: 6
    Last Post: 08-21-2008, 09:30 PM
  5. key pressed event
    By kavithas in forum New To Java
    Replies: 7
    Last Post: 12-10-2007, 03:01 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