Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Hi All,

I'm trying to put a TextBox & a Button in a JOptionPane.showOptionDialog horizontally.
I've used this code
Java
JTextField txt = new JTextField();
JButton btn = new JButton("Button");
int value = JOptionPane.showOptionDialog(this,
                        new Object[]{txt, btn},
                        "Hello World",
                        JOptionPane.OK_CANCEL_OPTION, 
                        JOptionPane.INFORMATION_MESSAGE,
                        null, null, null);

But TextBox & Button showing vertically.
How can I show them in horizontally ?
Please help...
Thanks.
Posted

1 solution

That's handled this way by default.

If you want to have it different, you need to make your own dialog:

Tutorial JDialog[^] @ oracle.com
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900