JDK-4545951 : JOptionPane.showMessageDialog does not size dialog properly
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2001-12-03
  • Updated: 2022-09-14
  • Resolved: 2022-09-14
Related Reports
Duplicate :  
Description

Name: rmT116609			Date: 12/03/2001


java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)

also

java version "1.3.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)

JOptionPane.showMessageDialog() does not properly size the dialog to fit all
its contents. The OK button is pushed off the bottom of the dialog.

Here is a test cases using a JTextArea for the message component. The JTextArea
is properly sized, but the dialog is not any taller and so the OK button almost
disappears.

import javax.swing.*;
public class OptTest {
	public static void main(String args[]) {
		JTextArea msg = new JTextArea("one two three four five six"+
"seven eight nine ten one two three four five six seven eight nine ten one two"+
"three four five six seven eight nine ten one two three four five six seven"+
"eight nine ten one two three four five six seven eight nine ten one two three"+
"four five six seven eight nine ten", 0, 40);
		msg.setLineWrap(true);
		JOptionPane.showMessageDialog(null, msg);
		System.exit(0);
	}
}
(Review ID: 136681) 
======================================================================

Comments
EVALUATION Able to reproduce this under 1.3.1 and 1.4beta3. There are some possible workarounds. Need to investigate more.
25-09-2004

WORK AROUND Place the text area in a scrollpane. Or use a string delimiting lines by a \n. ###@###.### 2001-12-04
04-12-2001