Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-08-2007, 06:37 AM
Member
 
Join Date: Nov 2007
Posts: 8
mandrake446 is on a distinguished road
Yes/No confirm dialog box
I was just wondering how to creat a "yes / no" dialog box. I can create a dialog boxes with the choice for "ok/ 'x' in the corner" its just

import javax.swing.JOptionPane; //before the class declaration

JOptionPane.showMessageDialog(null, "Are you an idiot?"); //in the class



i was just wondering if someone could show me the code for a "yes/no" option dialog box.

Thanks,
Mandrake




edit: What i'm trying to do is use a yes/no dialog box as the control for a loop where if "yes" is selected the loop will run though again, but terminates if "no" is selected.

example:

Do you want more money?

Yes: (loop causes your taxes to raise)
yes: (loop causes your taxes to raise)
yes: (loop causes your taxes to raise)

No:(loop terminates, not raising your taxes)

Last edited by mandrake446 : 12-08-2007 at 06:55 AM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-08-2007, 09:27 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,124
hardwired is on a distinguished road
Code:
import javax.swing.JOptionPane; public class OptionLoop { public static void main(String[] args) { System.out.printf("JOptionPane.YES_OPTION = %d%n" + "JOptionPane.NO_OPTION = %d%n" + "JOptionPane.CLOSED_OPTION = %d%n", JOptionPane.YES_OPTION, JOptionPane.NO_OPTION, JOptionPane.CLOSED_OPTION); int more = JOptionPane.YES_OPTION; do { more = JOptionPane.showConfirmDialog(null, "Want more?", "Input", JOptionPane.YES_NO_OPTION); System.out.println("more = " + more); } while(more == JOptionPane.YES_OPTION); } }
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-09-2007, 06:31 AM
Member
 
Join Date: Nov 2007
Posts: 8
mandrake446 is on a distinguished road
Thank you
Thank You!
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run As dialog and Plugin Help menelaosbgr Eclipse 0 03-25-2008 04:21 AM
Example - File Dialog Java Tip Java Tips 0 03-01-2008 11:11 PM
Example of SWT Dialog Java Tip Java Tips 0 01-09-2008 01:01 PM
SWT Dialog JavaForums Java Blogs 0 12-31-2007 05:53 PM
Dialog Box uncopywritable New To Java 2 07-30-2007 01:42 PM


All times are GMT +3. The time now is 12:51 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org