JDK-4244132 : BorderFactory.createTitledBorder() slightly broken in 1.2.2
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1999-06-04
  • Updated: 1999-12-21
  • Resolved: 1999-12-21
Related Reports
Duplicate :  
Description

Name: skT88420			Date: 06/04/99


If BorderFactory.createTitledBorder() is used to create a border under JDK1.2.2 and the DEFAULT_JUSTIFICATION and DEFAULT_POSITION constants are used to specify the location of the title, the border is drawn underneath the label.  There should not be a border under the label text.

The following code demonstrates the problem.  This worked properly in 1.2.1.

import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;

public class BorderTest extends JPanel
{
	public BorderTest()
	{
		setBorder(BorderFactory.createCompoundBorder(
	        	    BorderFactory.createTitledBorder(
		                BorderFactory.createEtchedBorder(), "There Should Not Be a Border Underneath This Text!",
		                TitledBorder.DEFAULT_JUSTIFICATION,
		                TitledBorder.DEFAULT_POSITION,
		                new Font("Helvetica", Font.PLAIN, 12)),
		            BorderFactory.createEmptyBorder(5, 5, 5, 5)));
	}

	public static void main(String[] args)
	{
		JFrame f = new JFrame("Border Test");
		Container c = f.getContentPane();
		c.setLayout(new BorderLayout());
		c.add(new BorderTest(), "Center");
		f.setBounds(20, 20, 500, 400);
		f.setVisible(true);
	}
}
(Review ID: 83961) 
======================================================================

Comments
WORK AROUND Name: skT88420 Date: 06/04/99 Use TitledBorder.LEFT and TitledBorder.TOP instead of TitledBorder.DEFAULT_JUSTIFICATION and TitledBorder.DEFAULT_POSITION, respectively. ======================================================================
11-06-2004