How to widen JOptionPane without writing a custom one?

sciuriware
sciuriware used Ask the Experts™
on
I practise an input-text dialog as follows:

            String answer = (String)JOptionPane.showInputDialog
            (
               mainFrame,
               question,
               "Input text",
               JOptionPane.QUESTION_MESSAGE,
               textIcon,
               null,
               presetText
            );
 
Now, if the preset is longer than +- 25 characters, only a portion of it is shown.
You can't widen the dialog by the cursor, so, is there a way to 'pack()' the dialog,
so that all preset text becomes visible?
I'd rather not write a custom dialog in this case.

;JOOP!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016
Commented:
You might try

 new Object[] { presetText }

as your penultimate parameter instead of null

Author

Commented:
You did it again!

;JOOP!

Author

Commented:
Concise and right to the point.
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Top Expert 2016

Commented:
:-)

Author

Commented:
I was too quick (and excited):

The solution is (nearly) perfect, but .................................

................. the shown textfield is no longer editable .....................

And that was mandatory.
Any idea?

;JOOP!
Top Expert 2016

Commented:
I didn't thing editable options were supported ... ;-)

Author

Commented:
If you set the Objects[] to null, the text field with the preset text is editable.

OK, work to do: make a custom dialog, make it singleton (re-use) etc. etc.
Anyway, learned a lot today.
;JOOP!
Top Expert 2016

Commented:
Hmm. Didn't know that

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial