JOptionPane buttons

How do you get JOptionPane to display 2 or 3 rows of buttons? Is it even possible? If not, then what are other options (I would need something that when you click a button, it returns a specified value).
[210 byte] By [TrueAcea] at [2007-10-2 20:28:30]
# 1
Roll your own
Arbiea at 2007-7-13 23:11:26 > top of Java-index,Java Essentials,New To Java...
# 2
[url= http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html]How to Make Dialogs[/url]~
yawmarka at 2007-7-13 23:11:26 > top of Java-index,Java Essentials,New To Java...
# 3

> [url=http://java.sun.com/docs/books/tutorial/uiswing/c

> omponents/dialog.html]How to Make Dialogs[/url]

>

> ~

Look out! Rerun coming.......

What yawmark says is always true

He's told me things I never knew

At times I had a bit of doubt

So I would go and check it out

But now I never waste my time

I'd simply rather make a rhyme

And when he tells me something new

I'll swear to you it's really true

kr

R.B.

Arbiea at 2007-7-13 23:11:27 > top of Java-index,Java Essentials,New To Java...
# 4
> What yawmark says is always trueThat's far too generous.~
yawmarka at 2007-7-13 23:11:27 > top of Java-index,Java Essentials,New To Java...
# 5

Here is an example from Fred Swartz.

[url=http://leepoint.net/notes-java/index.html]Java Programming Notes - Fred Swartz[/url]

import javax.swing.JOptionPane;

public class JOptionPaneTest2 {

public static void main(String[] args) {

String[] choices = {"Democratic", "Republican",

"None of your business", "Comunist", "Socialist", "Complete Jackoff"};

int doAgain;

do {

int response = JOptionPane.showOptionDialog(

null// center over parent

, "How did you vote?"// message

, "Party Poll"// title in titlebar

, JOptionPane.YES_NO_OPTION // Option type

, JOptionPane.PLAIN_MESSAGE // messageType

, null// icon

, choices// Options

, "None of your business"// initial value

);

JOptionPane.showMessageDialog(null, "Response = " + response);

doAgain = JOptionPane.showConfirmDialog(null, "Again?");

} while (doAgain == JOptionPane.YES_OPTION);

System.exit(0);

}

}

You can show more, but it gets ugly..

I would look into extending the JDialog and laying out the buttons the way you want.

JJ

Java_Jaya at 2007-7-13 23:11:27 > top of Java-index,Java Essentials,New To Java...
# 6
okay, I did some research on JDialog and couldn't really find anything that could help me very much. I already know how to use JOptionPane, just couldn't figure out how to get 7 buttons to show on three different lines.do you know where a good tutorial is?
TrueAcea at 2007-7-13 23:11:27 > top of Java-index,Java Essentials,New To Java...
# 7
Anyone? If it is not possible, please say so.
TrueAcea at 2007-7-13 23:11:27 > top of Java-index,Java Essentials,New To Java...
# 8
> Anyone? If it is not possible, please say so.It is certainly possible with a JDialogkrRB
Arbiea at 2007-7-13 23:11:27 > top of Java-index,Java Essentials,New To Java...
# 9
So it's not possible with JOptionPane?I am trying to avoid the messiness of having to make sperate classes and methods just for a button (and I have 7 buttons)
TrueAcea at 2007-7-13 23:11:27 > top of Java-index,Java Essentials,New To Java...
# 10

> okay, I did some research on JDialog and couldn't

> really find anything that could help me very much. I

> already know how to use JOptionPane, just couldn't

> figure out how to get 7 buttons to show on three

> different lines.

>

The UI handles the layout.

You may need to write your own UI.

here's a reference of where to start.

[url]http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/plaf/basic/BasicOptionPaneUI.html[/url]

kr

arbie

Arbiea at 2007-7-13 23:11:27 > top of Java-index,Java Essentials,New To Java...