[Logo]
Forums Register Login
Make buttons in JoptionPane
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?
Read this: http://download.oracle.com/javase/tutorial/uiswing/components/dialog.html
 
Kevin Workman wrote:Read this: http://download.oracle.com/javase/tutorial/uiswing/components/dialog.html


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'
 
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
Check the "Creating and Showing Simple Dialogs" section, sub section "showOptionDialog".
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?
Did you download the demo code and test it?

What part of the working example from the tutorial do you not understand?
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?
Fixed it.

/thread
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Nov 23, 2017 00:53:53.