JDK-7010555 : TitledBorder insets vary
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86
  • Submitted: 2011-01-05
  • Updated: 2012-03-20
  • Resolved: 2011-04-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7Resolved
Related Reports
Duplicate :  
Description
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 ----------