• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Dual inputs in JOptionPane ( Is it possible)?  RSS feed

 
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
 
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
 
author and iconoclast
Sheriff
Posts: 24220
40
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
 
Bartender
Posts: 9511
12
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!