• Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating custom inputfield in a JOptionPane  RSS feed

 
Hema Menon
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Does anyone know whether it is possible to change the input box in a JOptionPane.showInputDialog()? I want the input field to enter only a selected values. I have a custom component which extends the JTextField to do the validation. I wonder if it is possible to add this custom textfield inplace of the input field in a showInputDialog.
Any help appreciated,

Thanks
Hema
 
zoe goddard
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at extending a PlainDocument to create your own custom input field
 
Matt Robinson
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll have to create your own dialog if you want customized input fields. JOptionPane can't handle this by default.
------------------
Matthew Robinson co-author of "Swing" (1999, Manning Publications). Freely available at http://www.spindoczine.com/sbe
 
mick barry
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can achieve this with a bit of a kludge. TRy:
JTextField tf = ...;
JOptionPane.showMessageDialog(parent, tf);
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!