JDK-5060610 : Trailing character's getting clipped in JLable
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2004-06-09
  • Updated: 2006-10-20
  • Resolved: 2006-10-20
Related Reports
Duplicate :  
Duplicate :  
Description
Name: dk106046			Date: 06/09/2004

OPERATING SYSTEM(S):
RedHat Linux

FULL JDK VERSION(S):
java version "1.4.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_04-b04)
Java HotSpot(TM) Client VM (build 1.4.0_04-b04, mixed mode)

java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b06)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b06, mixed mode)

java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b45)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b45, mixed mode)


On running the swing motifLookandFeel  testcase with JDK we see that the trailing last character of text content of JLabel is getting truncated /clipped.
The truncation is see only on some characters such as "w" or "v" or "y". So we can say the clipping is occurring only on the character which has a right hand side elevations.

Run the testcase with JDK 1.4.X and JDK 1.5 X.

import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
                                                                                                                                             
public class TestCzech {
                                                                                                                                             
  public static void main(String args[]) {
    String motifClass = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
    //String motifClass = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
    try {
      UIManager.setLookAndFeel(motifClass);
    } catch (ClassNotFoundException e) {
      System.out.println("couldn't find" + motifClass);
    } catch (Exception e2) {
      System.out.println(e2);
    }
                                                                                                                                             
    JFrame frame = new JFrame("Test Czech");
    JButton jb = new JButton("hav");
    JLabel jl = new JLabel ("monkey");
    JPanel jPanel = new JPanel();
    jPanel.setLayout(new BorderLayout());
    JPanel btnPanel = new JPanel();
    btnPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
    btnPanel.add(jb);
    jPanel.add(btnPanel);
    jPanel.add(btnPanel,"South");
    jPanel.add(jl);
    jPanel.add(jl,"West");
    frame.getContentPane().add(jPanel);
    frame.addWindowListener( new WindowAdapter()
                {
                        public void windowClosing( WindowEvent e )
                        {
                                System.exit(0);
                        }
                } );
    frame.pack();
    frame.setVisible(true);
                                                                                                                                             
                                                                                                                                             
  }
}

Additional configuration information:
Default Xwindows setting. No additional setting required.

======================================================================

Comments
EVALUATION This bug is the same as 6464003. I'm working on a fix.
20-10-2006

EVALUATION This is happening because Swing is not measuring the pixel bounds. Unfortunately to start measuring the pixel bounds is much more costly and will likely effect the size of a whole lot of widgets. More investigation and work with 2D team is required. ###@###.### 2004-06-10
10-06-2004

WORK AROUND Name: dk106046 Date: 06/09/2004 Increase the pixel size or the font size. ====================================================================== Create a custom UI that pads the preferred width by a couple of pixels. ###@###.### 2004-06-10
10-06-2004