Results 1 to 4 of 4

Thread: JDialog

  1. #1
    frenk_castle is offline Member
    Join Date
    Mar 2010
    Location
    Belgrade, Serbia
    Posts
    27
    Rep Power
    0

    Default JDialog

    In my application there is a Print setup button. In the action listener for that button I want to create a JDialog. I want to read data from print setup buffer and use that data to set components in JDialog. I want then to show this JDialog in the modal capacity and let make some input. I know pretty much how to do what I want up to this point.

    I need to have ok and cancel buttons in the bottom of the dialog. I want for my dialog to close when user click on the x in the top right corner, and I what print setup button action listener to be able to tell that the user didn't clicked ok and to ignore all changes. If the user click cancel I want same response. Dialog to close action listener to ignore the changes. But if the user clicks ok I want dialog to close and for action listener to copy all dialog data I am interested in to print setup buffer. Does Java have predefined Dialog class that has this behavior or do I have to do all this by my self. Basically I need to close dialog on all three occasions and to be able to decide did user clicked ok or not when dialog closed.

    I googled the net but failed to find any useful information. Any link to some tutorial on this topic will be very helpful.

    Thanks in advance

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

    Default

    Nope, you have to do it yourself, but it's pretty easy. Use a boolean savechanges :
    Java Code:
    public class PrintDialog extends JDialog.....{
        private boolean saveChanges = false;
    
        public void actionPerformed(ActionEvent e){
            if(e.getSource == okButton){
                saveChanges = true;
            }
            // close after ok and cancel
            this.setVisible(false);
        }
    }
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    frenk_castle is offline Member
    Join Date
    Mar 2010
    Location
    Belgrade, Serbia
    Posts
    27
    Rep Power
    0

    Default

    When I see how ease it is I officially feel stupid. Thank you.

  4. #4
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

    Default

    No need to :) You're welcome.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

Similar Threads

  1. Close JDialog
    By sky in forum AWT / Swing
    Replies: 7
    Last Post: 11-16-2009, 06:01 PM
  2. Open jDialog problem
    By jicxicmic in forum AWT / Swing
    Replies: 2
    Last Post: 11-13-2009, 01:06 PM
  3. JProgressBar inside a JDialog
    By Mikey_S in forum AWT / Swing
    Replies: 10
    Last Post: 07-13-2009, 02:55 PM
  4. setLocation on a JDialog is ignored
    By ScottVal in forum AWT / Swing
    Replies: 7
    Last Post: 01-13-2009, 07:35 AM
  5. help with jdialog
    By leonard in forum AWT / Swing
    Replies: 1
    Last Post: 08-05-2007, 05:37 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
  •