FULL PRODUCT VERSION :
java version "1.5.0_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
After I call JButton#setBorder(), WindowsButtonListener set it back to the default border.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the sample code I posted and run. You'll get the result from stderr.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
With JDK 1.5.0_06 I got this result:
border: null
preferredSize: java.awt.Dimension[width=23,height=13]
ACTUAL -
With JDK 1.5.0_08, I got this result:
border: com.sun.java.swing.plaf.windows.XPStyle$XPEmptyBorder@8ed465
preferredSize: java.awt.Dimension[width=55,height=21]
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.*;
public class Test
{
public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
final JFrame frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
final JButton button = new JButton("Test");
button.setBorder(null);
// button.setBorderPainted(false);
// button.setContentAreaFilled(false);
// button.setFocusable(false);
// button.setFocusPainted(false);
// button.setOpaque(false);
// button.setMargin(new Insets(0, 0, 0, 0));
frame.getContentPane().add(button);
frame.pack();
frame.setVisible(true);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
System.err.println("border: " + button.getBorder());
System.err.println("preferredSize: " + button.getPreferredSize());
}
});
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Create a class derived from JButton and override setBorder to do nothing.
Release Regression From : 5.0u6
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.