-
Bug
-
Resolution: Fixed
-
P2
-
1.4.2
-
b19
-
sparc
-
solaris_8
-
Verified
1. STEPS TO REPRODUCE
- run attached sample
- push button
-> you will see that dialog is resized and returned value are different when you run it on JDK 1.4.1 and JDK1.4.2, strictly speaking value on JDK1.4.2(build16) is extremely high !
=======================================
2. OUTPUT FROM SAMPLE
-----
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
JDialog.getSize()=java.awt.Dimension[width=300,height=300]
JDialog.getMinimumSize()=java.awt.Dimension[width=90,height=86]
-----
java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b16)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b16, mixed mode)
JDialog.getSize()=java.awt.Dimension[width=300,height=300]
JDialog.getMinimumSize()=java.awt.Dimension[width=90,height=6580]
!!! height of the JDialog.getMinimumSize() is too high on j2sdk1.4.2_b16!!!
========================
3. SAMPLE CODE
----------- %< ------------------
import java.awt.*;
import javax.swing.*;
import javax.swing.event.ChangeListener;
/*
* This class creates dialog which contains button. Pressing
* button adds JTextArea. After addin text area the dialog is
* resized accoring to its minimal size.
*/
public class TestMain {
public TestMain() {
}
private JDialog jd;
public void test() {
jd = new JDialog();
jd.setModal(true);
jd.setSize(300,300);
jd.getContentPane().add(new ButtonPanel());
jd.show();
}
public static void main(String[] args) {
TestMain tm = new TestMain();
tm.test();
}
public class ButtonPanel extends javax.swing.JPanel {
private javax.swing.JButton jButton1;
public ButtonPanel() {
initComponents();
}
private void initComponents() {
jButton1 = new javax.swing.JButton();
setLayout(new BorderLayout());
jButton1.setText("clickMe");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
add(jButton1, BorderLayout.SOUTH);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
add(new TextPanel(), BorderLayout.CENTER);
// Force dialog to resize.
// The getMinimumSize() & setSize() calls might not be necessary,
// but should work I think. After fix of 4410243 it does not.
Dimension sz = jd.getSize();
System.err.println("JDialog.getSize()="+sz);
Dimension minsz = jd.getMinimumSize();
System.err.println("JDialog.getMinimumSize()="+minsz);
System.err.println("!!! height of the JDialog.getMinimumSize() is too high on j2sdk1.4.2_b16!!!");
if (minsz.width > sz.width || minsz.height > sz.height) {
jd.setSize(Math.max(minsz.width, sz.width), Math.max(minsz.height, sz.height));
}
jd.validate();
jd.repaint();
}
}
public class TextPanel extends javax.swing.JPanel {
private javax.swing.JTextArea jTextArea1;
public TextPanel() {
initComponents();
}
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jTextArea1 = new javax.swing.JTextArea();
setLayout(new java.awt.GridBagLayout());
jTextArea1.setLineWrap(true);
jTextArea1.setText("random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0);
add(jTextArea1, gridBagConstraints);
}
}
}
------------ >% ------------------------------
- run attached sample
- push button
-> you will see that dialog is resized and returned value are different when you run it on JDK 1.4.1 and JDK1.4.2, strictly speaking value on JDK1.4.2(build16) is extremely high !
=======================================
2. OUTPUT FROM SAMPLE
-----
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
JDialog.getSize()=java.awt.Dimension[width=300,height=300]
JDialog.getMinimumSize()=java.awt.Dimension[width=90,height=86]
-----
java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b16)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b16, mixed mode)
JDialog.getSize()=java.awt.Dimension[width=300,height=300]
JDialog.getMinimumSize()=java.awt.Dimension[width=90,height=6580]
!!! height of the JDialog.getMinimumSize() is too high on j2sdk1.4.2_b16!!!
========================
3. SAMPLE CODE
----------- %< ------------------
import java.awt.*;
import javax.swing.*;
import javax.swing.event.ChangeListener;
/*
* This class creates dialog which contains button. Pressing
* button adds JTextArea. After addin text area the dialog is
* resized accoring to its minimal size.
*/
public class TestMain {
public TestMain() {
}
private JDialog jd;
public void test() {
jd = new JDialog();
jd.setModal(true);
jd.setSize(300,300);
jd.getContentPane().add(new ButtonPanel());
jd.show();
}
public static void main(String[] args) {
TestMain tm = new TestMain();
tm.test();
}
public class ButtonPanel extends javax.swing.JPanel {
private javax.swing.JButton jButton1;
public ButtonPanel() {
initComponents();
}
private void initComponents() {
jButton1 = new javax.swing.JButton();
setLayout(new BorderLayout());
jButton1.setText("clickMe");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
add(jButton1, BorderLayout.SOUTH);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
add(new TextPanel(), BorderLayout.CENTER);
// Force dialog to resize.
// The getMinimumSize() & setSize() calls might not be necessary,
// but should work I think. After fix of 4410243 it does not.
Dimension sz = jd.getSize();
System.err.println("JDialog.getSize()="+sz);
Dimension minsz = jd.getMinimumSize();
System.err.println("JDialog.getMinimumSize()="+minsz);
System.err.println("!!! height of the JDialog.getMinimumSize() is too high on j2sdk1.4.2_b16!!!");
if (minsz.width > sz.width || minsz.height > sz.height) {
jd.setSize(Math.max(minsz.width, sz.width), Math.max(minsz.height, sz.height));
}
jd.validate();
jd.repaint();
}
}
public class TextPanel extends javax.swing.JPanel {
private javax.swing.JTextArea jTextArea1;
public TextPanel() {
initComponents();
}
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jTextArea1 = new javax.swing.JTextArea();
setLayout(new java.awt.GridBagLayout());
jTextArea1.setLineWrap(true);
jTextArea1.setText("random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text random text");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0);
add(jTextArea1, gridBagConstraints);
}
}
}
------------ >% ------------------------------
- relates to
-
JDK-4410243 JTextArea within JScrollPane using the GridBagLayout will flicker
-
- Open
-