Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Dual inputs in JOptionPane ( Is it possible)?

 
joe kane
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I was wondering is it possible for there to be 2 input boxes in one JOptionPane?

This Displays 1 input box but can I have two?
e.g.

Is it possible?
Thanks loads in advance
Thanks Joe Kane
 
Barry Andrews
Ranch Hand
Posts: 529
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, check out this method.

Make your Object[] JTextField objects.

Barry
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Swing forum.
 
joe kane
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for that, but I am a noob to Java and do not fully understand your code,
where do I put the "inputDialog" etc...
Message Box
___________________________________________
First Name: [____]
Second Name: [____]
___________________________________________
with an information message, how would I doo this?
Thanks in advance Joe Kane
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are a noob, check out the Java Tutorial. Tons of great examples, like this section on How to Make Dialogs
[ April 08, 2004: Message edited by: Joe Ess ]
 
Barry Andrews
Ranch Hand
Posts: 529
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry buddy, I am wrong...
The JavaDocs suggest (at least to me) that you can pass whatever Component type you want and it will lay it out for you. From the JavaDocs: " It is up to the UI to decide how best to represent the selectionValues, but usually a JComboBox, JList, or JTextField will be used." However when I tried the sample code below, you get a combo box instead of 2 text fields. I would suggest using a JDialog instead and creating your own dialog from scratch. This method would not have worked anyway, because you probably want to have a label next to each edit field, and there is no way to do that here. Again, sorry for being misleading. Hope this helps!
Barry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!