-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.2.0, 1.2.2, 1.4.0
-
generic, x86, sparc
-
generic, solaris_2.5.1, windows_95, windows_2000
Name: rk38400 Date: 11/10/98
My test case has a JTextField in a panel. The
textfield is set to a width of 20 columns. If the
frame is resized so that the width of the panel is
barely less than the original width of the
textfield, then the textfield suddenly shrinks to
almost zero width. This did not happen in 1.2b4.
Here is my test case:
---------TFBug.java: cut here------
import javax.swing.*;
import java.awt.*;
/**
* This class demonstrates a layout bug in RC1. When it comes up, the right side
* of the frame is past the edge of the textfield, and it looks fine. If you
* grab the right edge of the frame and move it so the width of the frame is just
* less than the original width of the textfield, when you release the frame
* drag, the textfield will suddenly shrink to almost zero length. This does not
* happen in 1.2beta4.
*/
public class TFBug
{
public static void main(String[] args)
{
JFrame frame = new JFrame("TFBug");
JPanel panel = new JPanel(new GridBagLayout());
frame.setContentPane(panel);
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 2;
gbc.gridheight = 1;
gbc.fill = GridBagConstraints.NONE;
gbc.anchor = GridBagConstraints.WEST;
gbc.weightx = 1.0;
gbc.weighty = 0.0;
JTextField field = new JTextField();
field.setColumns(20);
panel.add(field, gbc);
frame.setSize(400, 100);
frame.show();
}
}
---------TFBug.java: cut here------
(Review ID: 42055)
======================================================================
Name: skT88420 Date: 07/15/99
Problem :
JTextField with a fixed columnsize which is too big for
a fixed sized JPanel with layoutmanager GridBagLayout
makes the size of the JTextField zero !
Reproduction :
The sourcecode gives a JTextField of 0.
If you change JTextField(21) in JTextField(20) everything
is allright.
Source Code :
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
class Test
{
private JLabel l1 = new JLabel("Document1");
private JTextField t1 = new JTextField(21);
public Test()
{
GridBagLayout gbl;
GridBagConstraints c;
JFrame f = new JFrame();
JPanel p = new JPanel();
gbl = new GridBagLayout();
c = new GridBagConstraints();
p.setLayout(gbl);
c.gridx = 0;
c.gridy = 0;
c.anchor = GridBagConstraints.WEST;
c.insets = new Insets(1, 1, 1, 1);
p.add(l1, c);
c.gridx = 1;
p.add(t1, c);
JPanel p1 = new JPanel();
gbl = new GridBagLayout();
c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 0;
c.weightx = 1.0;
c.weighty = 1.0;
c.anchor = GridBagConstraints.NORTHWEST;
c.insets = new Insets(1, 1, 1, 1);
p1.setLayout(gbl);
p1.add(p, c);
f.getContentPane().add(BorderLayout.CENTER, p1);
f.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
});
f.setSize(300, 100);
f.setVisible(true);
}
static public void main(String args[])
{
new Test();
}
}
(Review ID: 85603)
======================================================================
Name: skT88420 Date: 07/26/99
Compile and run the following program. Then resize the window
larger, and then smaller. When you make it larger, the JTextArea
expands to the new size (leaving room for the JComboBox), when
you shrink it, the JTextArea stays large, and the JComboBox goes
off-window.
Z:\carlson\infact\classes>java -version
java version "1.2.2"
Classic VM (build JDK-1.2.2-W, native threads, symcjit)
Z:\carlson\infact\classes>java -fullversion
java full version "JDK-1.2.2-W"
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class bug3 extends JPanel {
public bug3() {
setLayout(new BorderLayout());
Container details = Box.createHorizontalBox();
Container c = Box.createHorizontalBox();
Container d = Box.createVerticalBox();
c.add(Box.createHorizontalGlue());
c.add(new JLabel("Description"));
c.add(Box.createHorizontalGlue());
d.add(c);
c = Box.createHorizontalBox();
JTextArea description = new JTextArea(3, 50);
description.setLineWrap(true);
description.setWrapStyleWord(true);
c.add(Box.createHorizontalGlue());
c.add(description);
c.add(Box.createHorizontalGlue());
d.add(c);
details.add(d);
c = Box.createHorizontalBox();
d = Box.createVerticalBox();
c.add(Box.createHorizontalGlue());
c.add(new JLabel("Level"));
c.add(Box.createHorizontalGlue());
d.add(c);
Object levels[] = {"",
new Integer(0), new Integer(1), new Integer(2),
new Integer(3), new Integer(4), new Integer(5),
new Integer(6), new Integer(7), new Integer(8),
new Integer(9)};
JComboBox level = new JComboBox(levels);
c = Box.createHorizontalBox();
c.add(Box.createHorizontalGlue());
c.add(level);
c.add(Box.createHorizontalGlue());
d.add(c);
details.add(d);
add(details, BorderLayout.CENTER);
}
public static void main(String args[]) {
JFrame frame = new JFrame("bug3");
java.awt.Container contentPane = frame.getContentPane();
contentPane.setLayout(new BorderLayout());
bug3 b3 = new bug3();
contentPane.add(b3, BorderLayout.CENTER);
frame.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.pack();
frame.setVisible(true);
}
}
(Review ID: 85588)
======================================================================
- duplicates
-
JDK-4803949 JTextField integer contructor fails when used with GridBagLayout in JApplet
-
- Closed
-
- relates to
-
JDK-4197991 Scrollbars work incorrectly when resizing a window.
-
- Closed
-