JDK-4247606 : BorderedPane appears wrong with Title Position Below Bottom
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 1999-06-18
  • Updated: 2001-05-22
  • Resolved: 2001-05-22
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.4.0 beta2Fixed
Related Reports
Relates :  
Description
When running the swingset with kestrel-H, I noticed that when using the 
BorderedPane demo, and setting the Title Position to "Below Bottom", the 
title appears to be a little higher than it should be, and the bottom 
border is not painted.  

This bug also occurs in 1.2fcs and Cricket.  


Name: apR10133			Date: 04/23/2001


Here is the small testcase:
--------------------------- bug4247606.java ---------------------------
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;

public class bug4247606 extends JApplet {

    JPanel p = new JPanel();
    TitledBorder t;

    public void init() {
	JFrame fr = new JFrame("Test");
	fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	JPanel pane = new JPanel();
	pane.setBorder(new EmptyBorder(20,20,20,20));
	pane.setLayout(new BorderLayout());

	t = BorderFactory.createTitledBorder("Bordered Pane y");
	t.setTitlePosition(TitledBorder.BELOW_BOTTOM);
	//t.setTitleFont(new Font("Arial", Font.BOLD, 128));
	p.setBorder(t);
	p.setLayout(new BorderLayout());
	p.setBackground(Color.green);

	JButton bt = new JButton("Button");
	bt.setBorder(new LineBorder(Color.red, 5));
   
	p.add(bt);
       	pane.add(p);
	fr.getContentPane().add(pane);

	fr.setSize(300,200);
	fr.setVisible(true);
	System.out.println("bt:    "+   bt.getBounds());
	System.out.println("p:     "+    p.getBounds());
    }
    

    public static void main(String[] argv) {
	bug4247606 b = new bug4247606();
	b.init();
    }
}

###@###.###

Evaluated: yes
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic merlin-beta2 FIXED IN: merlin-beta2 INTEGRATED IN: merlin-beta2
24-08-2004

EVALUATION Further investigation reveals that the bug appears on Solaris 2.6, but not on Windows NT. I'm not sure exactly where to assign it (it could be a 2D problem with TextMetrics, or some AWT problem, etc.), so I'll leave it with the Swing Team for a first cut at evaluation. eric.hawkes@eng 1999-06-17 Name: apC97674 Date: 12/21/99 The bug is not reproducible with JDK1.3.0N and latest versions. ###@###.### ====================================================================== Name: apC97674 Date: 12/21/99 The text above applied only for Win NT. On Solaris 2.6 it's reproduced. ###@###.### ====================================================================== Name: apR10133 Date: 04/23/2001 The insets for TitledBorder was incorrectly calculated for the BELOW_BOTTOM case. The font ascents was used instead of font height. It's easy to show ascent's insufficietcy with the test case added at description. ###@###.### ======================================================================
24-08-2004

SUGGESTED FIX Name: apR10133 Date: 04/23/2001 ------- TitledBorder.java ------- *** /tmp/dFjaqwf Mon Apr 23 17:49:01 2001 --- TitledBorder.java Mon Apr 23 17:36:59 2001 *************** *** 402,407 **** --- 402,408 ---- FontMetrics fm; int descent = 0; int ascent = 16; + int height = 16; Border border = getBorder(); if (border != null) { *************** *** 436,441 **** --- 437,443 ---- if(fm != null) { descent = fm.getDescent(); ascent = fm.getAscent(); + height = fm.getHeight(); } switch (getTitlePosition()) { *************** *** 458,464 **** insets.bottom += ascent + descent; break; case BELOW_BOTTOM: ! insets.bottom += ascent + TEXT_SPACING; break; } return insets; --- 460,466 ---- insets.bottom += ascent + descent; break; case BELOW_BOTTOM: ! insets.bottom += height; break; } return insets; ###@###.### ======================================================================
24-08-2004