-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.0
-
x86
-
windows_xp
Name: jk109818 Date: 04/29/2003
FULL PRODUCT VERSION :
java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b19)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b19, mixed mode)
FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
The various border implementations in javax.swing.plaf.metal.MetalBorders should return copies of their border insets on getBorderInsets() calls.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the code given.
EXPECTED BEHAVIOR :
Insets are changed only for the menu item in question.
ACTUAL BEHAVIOR:
All menu items (Foo, Bar, and Baz) show up with a big gap on
the left, even though the insets are only being changed for menuitem1.
This bug does not occur for Windows LAFs.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.*;
/**
* @author Edward Lam
*/
public class TestFrame extends JFrame {
TestFrame() {
JMenuBar menubar = new JMenuBar();
JMenu menu = new JMenu("Foo");
JMenuItem menuitem1 = new JMenuItem("Bar");
JMenuItem menuitem2 = new JMenuItem("Baz");
menubar.add(menu);
menu.add(menuitem1);
menu.add(menuitem2);
setJMenuBar(menubar);
System.out.println(menuitem1.getMargin().left);
System.out.println(menuitem2.getMargin().left);
Insets insets = menuitem1.getInsets();
insets.left += 200;
menuitem1.setMargin(insets);
System.out.println(menuitem1.getMargin().left);
System.out.println(menuitem2.getMargin().left);
}
public static void main(String []s)
{
TestFrame testFrame = new TestFrame();
testFrame.pack();
testFrame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Create a copy of the Insets object that you receive before modifying it.
(Review ID: 184526)
======================================================================
FULL PRODUCT VERSION :
java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b19)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b19, mixed mode)
FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
The various border implementations in javax.swing.plaf.metal.MetalBorders should return copies of their border insets on getBorderInsets() calls.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the code given.
EXPECTED BEHAVIOR :
Insets are changed only for the menu item in question.
ACTUAL BEHAVIOR:
All menu items (Foo, Bar, and Baz) show up with a big gap on
the left, even though the insets are only being changed for menuitem1.
This bug does not occur for Windows LAFs.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.*;
/**
* @author Edward Lam
*/
public class TestFrame extends JFrame {
TestFrame() {
JMenuBar menubar = new JMenuBar();
JMenu menu = new JMenu("Foo");
JMenuItem menuitem1 = new JMenuItem("Bar");
JMenuItem menuitem2 = new JMenuItem("Baz");
menubar.add(menu);
menu.add(menuitem1);
menu.add(menuitem2);
setJMenuBar(menubar);
System.out.println(menuitem1.getMargin().left);
System.out.println(menuitem2.getMargin().left);
Insets insets = menuitem1.getInsets();
insets.left += 200;
menuitem1.setMargin(insets);
System.out.println(menuitem1.getMargin().left);
System.out.println(menuitem2.getMargin().left);
}
public static void main(String []s)
{
TestFrame testFrame = new TestFrame();
testFrame.pack();
testFrame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Create a copy of the Insets object that you receive before modifying it.
(Review ID: 184526)
======================================================================