Results 1 to 14 of 14
  1. #1
    Join Date
    Jan 2011
    Posts
    23
    Rep Power
    0

    Default Confirm Dialog box ?

    Hey ! I have a program where I want to ask the user if he wants to delete his account..for that I want to use a confirm dialog box, but I'm not exactly sure how I should handle the options...something like if yes is pressed do that, if no is pressed do that .

    Java Code:
    int no  = JOptionPane.NO_OPTION;
    int yes = JOptionPane.YES_OPTION;
    
    JOptionPane.showConfirmDialog(null, "Do you really want to delete your account ?");
    But how exactly do I verify if yes or no is pressed ?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,860
    Rep Power
    8

    Default

    Did you read the API? Check out the value returned from that method.

    Recommended reading: How to Make Dialogs (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Join Date
    Jan 2011
    Posts
    23
    Rep Power
    0

    Default

    Quote Originally Posted by KevinWorkman View Post
    Did you read the API? Check out the value returned from that method.

    Recommended reading: How to Make Dialogs (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
    yes..I actually read the java api and this tutorials everytime before posting here

  4. #4
    d3n1s is offline Member
    Join Date
    Apr 2011
    Posts
    69
    Rep Power
    0

    Default

    try int response = JOptionPane.showConfirmDialog(null, "Do you really want to delete your account ?");
    if (response == JOptionPane.YES_OPTION)
    {

  5. #5
    d3n1s is offline Member
    Join Date
    Apr 2011
    Posts
    69
    Rep Power
    0

    Default

    woops i hit the wrong button and it cut my post, but still you get the idea :D

  6. #6
    Join Date
    Jan 2011
    Posts
    23
    Rep Power
    0

    Default

    hehe yes:D...very helpfull, thank you !

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    'd3n1s', stop spoonfeeding and thus depriving others of a learning opportunity. Thanks.

    dn

  8. #8
    d3n1s is offline Member
    Join Date
    Apr 2011
    Posts
    69
    Rep Power
    0

    Default

    dude he was almost there, might as well complete it...

  9. #9
    Join Date
    Jan 2011
    Posts
    23
    Rep Power
    0

    Default

    I don't think posting always the links of those tutorials is a better help....I always go through them and I can't understand a thing...(it's just my opinion but they are really bad - I never found something useful)....if you have never done this kind of things, how can you learn them? He showed me the code, so that next time I know how it's done....so thanks again 'd3n1s'....maybe it's not right to ask for the code, but at least if you know the answer and want to help me, you could give me some little hints (again, not those links)...

  10. #10
    d3n1s is offline Member
    Join Date
    Apr 2011
    Posts
    69
    Rep Power
    0

    Default

    He read the tutorial, he did his homework. Sometimes you just need to see an example of it plugged into a working program to fully understand it.

  11. #11
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default

    Are you even aware how much sample code is present and linked from those tutorials?

    db

  12. #12
    d3n1s is offline Member
    Join Date
    Apr 2011
    Posts
    69
    Rep Power
    0

    Default

    Quote Originally Posted by DarrylBurke View Post
    Are you even aware how much sample code is present and linked from those tutorials?

    db
    Of course i am, a simple google search is very often all i've ever needed. Some people just come here first. I saw his question, i knew the answer and i answered it. It's not like i gave him his finished program it was like 3 lines of code dude. Chill out

  13. #13
    Join Date
    Jan 2011
    Posts
    23
    Rep Power
    0

    Default

    sorry 'd3n1s' for getting you into trouble....and mr. DarrylBurke, while the code might be simple to you, it isn't that simple to me...I bet you've got tons of experience, but I ain't yet...I wonder if you, in your first java programming years, could understand all that without any help at all.

  14. #14
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,335
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by ady_bavarezu89 View Post
    I wonder if you, in your first java programming years, could understand all that without any help at all.
    When I started programming there was no internet; I had to study books and learn from them (and the cryptic mumbling of my professors). It forced me to read and I can say that it pays back: I can manage to find and understand stuff on my own. If you're spoonfed you don't really learn and it makes you lazy; but I guess that's what it's all about with the 'google generation': they want instant response without putting in any effort themselves.

    kind regards,

    Jos (<--- dinosaur)
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Confirm dialog+pass parameters
    By barcelonax in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 12-21-2010, 08:20 AM
  2. dialog box
    By blindfolded916 in forum New To Java
    Replies: 5
    Last Post: 07-10-2010, 11:44 PM
  3. show Confirm Perspective Switch dialog box
    By mostafa in forum Eclipse
    Replies: 0
    Last Post: 11-22-2008, 11:47 AM
  4. Yes/No confirm dialog box
    By mandrake446 in forum Advanced Java
    Replies: 2
    Last Post: 12-09-2007, 05:31 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
  •