-
Bug
-
Resolution: Fixed
-
P4
-
1.4.1, 1.4.2, 5.0
-
b53
-
x86
-
windows_xp
Name: jk109818 Date: 08/15/2003
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Box disregards the background property even when set to opaque, which is
inconstent with the documented behaviour of Swing (in containers such as
JPanel).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a Box, set its background and place a glue in it. Set it to be opaque.
Yet when shown the background will not match the one set.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The background should appear correctly (see sample code and workaround)
ACTUAL -
The color is the default OS background color
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Color;
import javax.swing.*;
public class BoxTest extends JFrame {
/**
* Constructor for the BoxTest object
*/
public BoxTest() {
Box b = new Box(BoxLayout.X_AXIS);
// Uncomment these lines for a workaround
//JPanel b = new JPanel();
//b.setLayout(new BoxLayout(b, BoxLayout.X_AXIS));
b.setBackground(Color.PINK);
b.setOpaque(true);
b.add(Box.createGlue());
getContentPane().add("Center", b);
pack();
}
/**
* The main program for the BoxTest class
*
*@param argv The command line arguments
*/
public static void main(String[] argv) {
new BoxTest().show();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Replace:
Box b = new Box(BoxLayout.X_AXIS);
with:
JPanel b = new JPanel();
b.setLayout(new BoxLayout(b, BoxLayout.X_AXIS));
(Incident Review ID: 188567)
======================================================================
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Box disregards the background property even when set to opaque, which is
inconstent with the documented behaviour of Swing (in containers such as
JPanel).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a Box, set its background and place a glue in it. Set it to be opaque.
Yet when shown the background will not match the one set.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The background should appear correctly (see sample code and workaround)
ACTUAL -
The color is the default OS background color
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Color;
import javax.swing.*;
public class BoxTest extends JFrame {
/**
* Constructor for the BoxTest object
*/
public BoxTest() {
Box b = new Box(BoxLayout.X_AXIS);
// Uncomment these lines for a workaround
//JPanel b = new JPanel();
//b.setLayout(new BoxLayout(b, BoxLayout.X_AXIS));
b.setBackground(Color.PINK);
b.setOpaque(true);
b.add(Box.createGlue());
getContentPane().add("Center", b);
pack();
}
/**
* The main program for the BoxTest class
*
*@param argv The command line arguments
*/
public static void main(String[] argv) {
new BoxTest().show();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Replace:
Box b = new Box(BoxLayout.X_AXIS);
with:
JPanel b = new JPanel();
b.setLayout(new BoxLayout(b, BoxLayout.X_AXIS));
(Incident Review ID: 188567)
======================================================================
- duplicates
-
JDK-6405078 Can't set background in Box TableCellRenderer
-
- Closed
-
- relates to
-
JDK-4924235 1.4 REGRESSION: Box doesn't paint background as content pane
-
- Closed
-
-
JDK-4424085 Several Swing problems
-
- Closed
-