Duplicate :
|
FULL PRODUCT VERSION : java version "1.7.0-ea" Java(TM) SE Runtime Environment (build 1.7.0-ea-b121) Java HotSpot(TM) Client VM (build 20.0-b03, mixed mode) A DESCRIPTION OF THE PROBLEM : The insets of a TitledBorder will be modified by another method. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Execute the test case below and resize the window. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - The insets should stay unchanged. ACTUAL - Insets vary REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.awt.Component; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Insets; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.UIManager; import javax.swing.border.Border; import javax.swing.border.TitledBorder; public class TitledBorderInsetsTest extends JFrame { public static void main(String[] args) { EventQueue.invokeLater(new Runnable(){ public void run() { try { UIManager.put("TitledBorder.border", new MyTitledBorder()); new TitledBorderInsetsTest(); } catch (Exception e) { e.printStackTrace(); } } }); } public TitledBorderInsetsTest() throws Exception { JPanel p = new JPanel(); p.setBorder(new TitledBorder("Foo")); p.add(new JLabel("Label")); add(p); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(new Dimension(600, 300)); setLocationRelativeTo(null); setVisible(true); } public static class MyTitledBorder implements Border { private Insets insets = new Insets(20,20,20,20); @Override public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { System.err.println(insets); } @Override public Insets getBorderInsets(Component c) { return insets; } @Override public boolean isBorderOpaque() { return false; } } } ---------- END SOURCE ----------