-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.2.2
-
generic
-
generic
Name: skT88420 Date: 06/16/99
This behaves the same under Swing 1.1.x regardless of the JVM
(we've tested 1.1.7A through 1.2.2RC). It is a problem with
JTextField components used on a JPanel managed by GridBagLayout.
If any JTextField component in a column can't fit at its
preferred size, all JTextField components that aren't set for
horizontal fill that are in that column collapse to their
minimum size. (Under Swing 1.0.3, they all stubbornly cling to
their preferred sizes, whether or not they fit in their container
that way.)
This is a short test program to demonstrate the problem. When
you run it, size the frame until the longer of the two
JTextFields won't fit at its preferred size anymore. Both then
shrink to their minimum horizontal size. If you change the
import for swing to com.sun.java.swing.* you will see the fields
stay the same size and get clipped when you shrink the frame.
------------------------------------------------------------
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.*;
public class TestGBL extends javax.swing.JPanel
{
public TestGBL()
{
super();
initialize();
}
private void initialize()
{
setLayout(new GridBagLayout());
setSize(500, 120);
JTextField jtf;
GridBagConstraints gbc;
jtf = new JTextField();
jtf.setColumns(5);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 1;
gbc.gridheight = 1;
add(jtf, gbc);
jtf = new JTextField();
jtf.setColumns(15);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.gridwidth = 1;
gbc.gridheight = 1;
add(jtf, gbc);
}
public static void main(java.lang.String[] args)
{
JFrame jframe;
jframe = new JFrame();
jframe.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
TestGBL aTestGBL;
aTestGBL = new TestGBL();
jframe.setContentPane(aTestGBL);
jframe.setSize(aTestGBL.getSize());
jframe.setVisible(true);
}
}
------------------------------------------------------------
(Review ID: 84422)
======================================================================
Name: skT88420 Date: 06/18/99
This behaves the same under Swing 1.1.x regardless of the JVM
(we've tested 1.1.7A through 1.2.2RC). It is a problem with
JTextField components used on a JPanel managed by GridBagLayout.
If any JTextField component in a column can't fit at its
preferred size, all JTextField components that aren't set for
horizontal fill that are in that column collapse to their minimum
size. Under Swing 1.0.3, they all stubbornly cling to their
preferred sizes, whether or not they fit in their container that
way.
This is a short test program to demonstrate the problem. When
you run it, size the frame until the longer of the two
JTextFields won't fit at its preferred size anymore. Both then
shrink to their minimum horizontal size. If you change the
import for swing to com.sun.java.swing.* you will see the fields
stay the same size and get clipped when you shrink the frame.
------------------------------------------------------------
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.*;
public class TestGBL extends javax.swing.JPanel
{
public TestGBL()
{
super();
initialize();
}
private void initialize()
{
setLayout(new GridBagLayout());
setSize(500, 120);
JTextField jtf;
GridBagConstraints gbc;
jtf = new JTextField();
jtf.setColumns(5);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 1;
gbc.gridheight = 1;
add(jtf, gbc);
jtf = new JTextField();
jtf.setColumns(15);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.gridwidth = 1;
gbc.gridheight = 1;
add(jtf, gbc);
}
public static void main(java.lang.String[] args)
{
JFrame jframe;
jframe = new JFrame();
jframe.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
TestGBL aTestGBL;
aTestGBL = new TestGBL();
jframe.setContentPane(aTestGBL);
jframe.setSize(aTestGBL.getSize());
jframe.setVisible(true);
}
}
------------------------------------------------------------
(Review ID: 84537)
======================================================================