JDK-4243289 : Line drawn through TitledBorder
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.1,1.2.2
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,windows_98,windows_nt
  • CPU: generic,x86
  • Submitted: 1999-06-02
  • Updated: 1999-06-24
  • Resolved: 1999-06-24
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.
Other
1.3.0 betaFixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description

Name: vi73552			Date: 06/02/99


Creating a TitledBorder with another Border and Font, the background
of the title text is transparent.

I tried to unassign the font, that is, only set Border and this works ok.

With jdk1.2.1 works fine.

Source for a simple test:

/*
	TestTitledBorder.java
*/

import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;

import javax.swing.border.TitledBorder;

public class TestTitledBorder extends JFrame
	{
	static final int	WIDTH		= 300;
	static final int	HEIGHT	= 200;

	TestTitledBorder()
		{
		super("TitledBorder Test");

		addWindowListener(new TestCloser());

		Font fontPanel = new Font("Dialog", Font.PLAIN, 12);

		JPanel northPanel = new JPanel(true);
		northPanel.setBorder(
			BorderFactory.createTitledBorder(
				BorderFactory.createEtchedBorder(),
				"North Panel Title",
				TitledBorder.DEFAULT_JUSTIFICATION,
				TitledBorder.DEFAULT_POSITION,
				fontPanel
				)
			);

		JPanel centerPanel = new JPanel(true);
		centerPanel.setBorder(
			BorderFactory.createTitledBorder(
				BorderFactory.createEtchedBorder(),
				"Center Panel Title"
				)
			);

		getContentPane().add("North",northPanel);
		getContentPane().add("Center",centerPanel);
		pack();

		Dimension screenSize	=
						Toolkit.getDefaultToolkit().getScreenSize();
		setSize(WIDTH, HEIGHT);
		setLocation(screenSize.width/2 - WIDTH/2,
						screenSize.height/2 - HEIGHT/2);
		show();
		}

	public static void main(String args[])
		{
		new TestTitledBorder();
		}

	class TestCloser extends WindowAdapter
		{
		public void windowClosing(WindowEvent e)
			{
			System.exit(0);
			}
		}
	}
(Review ID: 83810) 
======================================================================

Name: vi73552			Date: 06/02/99


This paints the etching right through the border title
using jdk1.2.2.  Works fine using jdk1.2.1.
I am using windows 98 (unfortunately).  happens with 
metal L&F and Windows L&F.

import javax.swing.*;
import java.awt.Container;
import javax.swing.border.TitledBorder;
import java.awt.Font;
import java.awt.Color;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
class jdk1_2_2Bug
{
    public static void main(String[] args)
    {
        JFrame jframe=new JFrame();
        Container container=jframe.getContentPane();
        JPanel jpanel=new JPanel();
        jpanel.setLayout(new BoxLayout(jpanel, BoxLayout.X_AXIS));
        JLabel jlabel=new JLabel("Buggy titled border");
        jpanel.add(jlabel);
        container.add(jpanel);
        jpanel.setBorder(BorderFactory.createTitledBorder(null, 
          jlabel.getText(), 
          TitledBorder.DEFAULT_JUSTIFICATION, 
          TitledBorder.DEFAULT_POSITION, 
          new Font("Default", Font.PLAIN, 11), Color.black));
        jframe.pack();
        jframe.show();
        jframe.addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent we)
            {
                System.exit(0);
            }
        });
    }
}
(Review ID: 83773)
======================================================================

Name: vi73552			Date: 06/23/99


I use the instance of JPanel with such border:
TitledBorder titledBorder = new TitledBorder( newEtchedBorder( EtchedBorder.LOWERED ), "My Title", 0, 0, new Font("TimesRoman", 1, 11), Color.blue );

In all jdks I used ( 1.1.6 - 1.1.8 with jfc1.1beta1, 1.2.1 )everything looks good but in jdk1.2.2 etched line is visible under the title.
-------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import javax.swing.border.*;

public class borderTest extends JApplet
{
	boolean isStandalone = false;
	JPanel jPanel1 = new JPanel();
	JPanel jPanel2 = new JPanel();
    	TitledBorder newBorder = new TitledBorder( new EtchedBorder(
    		EtchedBorder.LOWERED ), "Add any component here", 0, 0, new
Font("TimesRoman", 1, 11), 		Color.blue );

	//Construct the applet
  	public borderTest()
	{
	}

	//Initialize the applet
  	public void init()
	{
		try 
		{
			jbInit();
		}
		catch(Exception e) 
		{
			e.printStackTrace();
		}
	}

	//Component initialization
  	private void jbInit() throws Exception
	{
		this.setSize(new Dimension(392, 325));
		this.getContentPane().add(jPanel1, BorderLayout.CENTER);
		jPanel1.add(jPanel2, null);
		jPanel1.setLayout(null);
		jPanel2.setBorder(newBorder);
		jPanel2.setBounds(new Rectangle(29, 32, 331, 118));
	}

	//Get Applet information
  	public String getAppletInfo()
	{
		return "Applet Information";
	}

	//Get parameter info
  	public String[][] getParameterInfo()
	{
		return null;
	}

	//Main method
  	public static void main(String[] args)
	{
		borderTest applet = new borderTest();
		applet.isStandalone = true;
		JFrame frame = new JFrame();
		frame.setTitle("Applet Frame");
		frame.getContentPane().add(applet, BorderLayout.CENTER);
		applet.init();
		applet.start();
		frame.setSize(400,320);
        		frame.addWindowListener(new
java.awt.event.WindowAdapter()
        		{
        			public  void windowClosing(WindowEvent e)
            		{
        				System.exit( 0 );
            		}
        		});
		Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
		frame.setLocation((d.width - frame.getSize().width) / 2,
(d.height - frame.getSize().height) / 2);
		frame.setVisible(true);
	}
	// static initializer for setting look & feel
	static 
	{
		try
		{
	
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
	
//UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName())
;
		}
		catch (Exception e) {}
	}
}


(Review ID: 84624)
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: kestrel-beta FIXED IN: kestrel-beta INTEGRATED IN: kestrel-beta
14-06-2004

WORK AROUND Name: vi73552 Date: 06/02/99 None. ====================================================================== Name: vi73552 Date: 06/02/99 subclass TitledBorder and re-write paintBorder. (Review ID: 83773) ======================================================================
11-06-2004

PUBLIC COMMENTS This was only happening with a title position of DEFAULT_POSITION, it has been fixed. scott.violet@eng 1999-06-04
04-06-1999

EVALUATION This was only happening with a title position of DEFAULT_POSITION, it has been fixed. scott.violet@eng 1999-06-04
04-06-1999