aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Make buttons in JoptionPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Make buttons in JoptionPane" Watch "Make buttons in JoptionPane" New topic
Author

Make buttons in JoptionPane

Jason Newman
Ranch Hand

Joined: Oct 20, 2010
Posts: 53
Hey, how do you make buttons on the JOption Pane? I know how to do it with the frame, but I am trying to make custom buttons for this pane. Like for example: Print out: How may I help you?" Button one :I'd like to ship, Button two: Uhh... Nevermind.

Please help?
Kevin Workman
Ranch Hand

Joined: Sep 28, 2010
Posts: 151
Read this: http://download.oracle.com/javase/tutorial/uiswing/components/dialog.html
Jason Newman
Ranch Hand

Joined: Oct 20, 2010
Posts: 53


I have a custom button made: But now how do I make the options pane show it?

JOptionPane panel = new JOptionPane();

JButton ship = new JButton("Ship a box");

panel.showMessageDialog(null, "Welcome to the Post Office, how may I help you?", "Welcome!",panel.);

It should say panel. something to show to button 'ship'
Kevin Workman
Ranch Hand

Joined: Sep 28, 2010
Posts: 151
Jason Newman wrote:


I have a custom button made: But now how do I make the options pane show it?


Read this: http://download.oracle.com/javase/tutorial/uiswing/components/dialog.html
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

Check the "Creating and Showing Simple Dialogs" section, sub section "showOptionDialog".


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jason Newman
Ranch Hand

Joined: Oct 20, 2010
Posts: 53
Okay. It runs, which makes me happy. So, one more question: How do I assign these buttons values? As in if one button is clicked, then you selected choice one, which therein goes to... Ect. Help?
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2177
    
    7
Did you download the demo code and test it?

What part of the working example from the tutorial do you not understand?
Jason Newman
Ranch Hand

Joined: Oct 20, 2010
Posts: 53
The part where it tells you how to assign int variables for the buttons. As in "Blarg" is clicked then you have selected the value of '1' so then you go ----> here. Or is "blah" is click then go ------>here.

Are you getting my issue?
Jason Newman
Ranch Hand

Joined: Oct 20, 2010
Posts: 53
Fixed it.

/thread
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Make buttons in JoptionPane