JDK-6420212 : Multi Line JOptionPane input dialogs
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2006-05-01
  • Updated: 2011-01-22
  • Resolved: 2007-05-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7Resolved
Related Reports
Duplicate :  
Description
java version "1.6.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-beta2-b73)
Java HotSpot(TM) Client VM (build 1.6.0-beta2-b73, mixed mode, sharing)

RFE for Multi Line JOptionPane input dialogs
Currently the JOptionPane.showInputDialog methods provide the user with a JTextField to enter 1 line of text. Sometimes we need the user to enter a paragraph of text.

Comments
EVALUATION I've heard back from the submitter of this RFE. There's one major limitation with the approach that I've suggested. That is, there's no easy way to ensure that the text area gets the default focus (like it does with the text field). I've proposed a work-around using a HierarchyListener, but they shouldn't have to do this: textArea.addHierarchyListener(new HierarchyListener() { public void hierarchyChanged(HierarchyEvent he) { if ((he.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) { if (textArea.isShowing()) { SwingUtilities.invokeLater(new Runnable() { public void run() { textArea.requestFocus(); } }); } } } }); We need to come up with a solution to allow them to specify the component that gets the focus by default. From what I can tell now, there should be no reason preventing us from adding this meaning to the "initialValue" parameter. It already allows you to give focus to one of the buttons...why not to any component in the pane?
04-05-2006

EVALUATION There is no need to add another static method to JOptionPane to support this. It's already supported indirectly by JOptionPane.showOptionDialog(). Here's a short snippet that will show a dialog with a text area for inputting text: JTextArea area = new JTextArea(5, 10); JScrollPane pane = new JScrollPane(area); int result = JOptionPane.showOptionDialog( this, new Object[] {"Label above the text area:", pane}, "Title", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (result == JOptionPane.OK_OPTION) { System.out.println(area.getText()); }
03-05-2006