Results 1 to 2 of 2
  1. #1
    Marcus is offline Member
    Join Date
    Jun 2007
    Posts
    92
    Rep Power
    0

    Default Close a JDialog Programmatically

    Do you know how can I close a JDialog from the code? the problem is the following
    I have a dialog with an interface a little bit hard, and 2 buttons: accept and cancel
    I want that when the user does click in accept saves the changes and closes the windows
    And when he clicks in cancel button closes without doing anything.

    I did that a JDialog be an ActionListener of the buttons, and when I click in some button, according to the string of the ActionCommand that comes in the ActionEvent as parameter of the method actionPerformed that implements JDialog.
    The problem is that I can't close the dialog.

    Marcus:cool:

  2. #2
    Eric is offline Senior Member
    Join Date
    Jun 2007
    Posts
    111
    Rep Power
    0

    Default

    Can you paste your code? maybe the problem is in your code
    anyway check this code.
    Java Code:
    public class MyDialog  extends JDialog {
      protected void processWindowEvent(WindowEvent e) {
        if(e.getID() == WindowEvent.WINDOW_CLOSING) {
          // Your code here.
        }

Similar Threads

  1. Replies: 1
    Last Post: 03-28-2008, 11:26 AM
  2. How to close a JFrame
    By valery in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 06:33 PM
  3. help with jdialog
    By leonard in forum AWT / Swing
    Replies: 1
    Last Post: 08-05-2007, 06:37 AM
  4. problems with jDialog in a JFrame
    By bbq in forum AWT / Swing
    Replies: 1
    Last Post: 07-05-2007, 05:14 AM
  5. Replies: 1
    Last Post: 04-09-2007, 01:05 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
  •