Unexpected padding to the left of the first letter / unexpected typographic behavior in JTextPane

I implemented a multi-line label by extending JTextPane. The constructor sets various properties to make it look like a label, including disabling any border / settings fields to 0 that work well.

Environment:

  • using jgoodies-looks-2.6.0
  • com.jgoodies.looks.windows.WindowsLookAndFeelL & F setup (also verified using javax.swing.plaf.metal.MetalLookAndFeelthe same issue)
  • Windows 8 x64
  • Java SE 1.7

When I increase the font size, the first letter sometimes has an "empty space" / margin ~ 1px of 19pt (probably increasing with the font size) to the left of it. This happens, at least for the letters B, F, and L, but certainly not for A. Here is an example:

enter image description hereenter image description here

On the left, you can clearly see that the layout looks broken with a heading with this strange edge on the left. Note that the first line with the number (1861) is regular JLabel.

Scaling confirms this (pink line for illustration):

enter image description hereenter image description here

So, because of what I see, the layout is incorrect.

Can this be considered a mistake in the swing? Is there any way to solve this? For instance. Is there a simple and understandable way (i.e. not paint) to have fine-grained control over typographic features in a swing in this context?

EDIT:

This is similar to what I expect:

enter image description hereenter image description here

vs before:

enter image description hereenter image description here

+4
source share
1 answer

If you look at your screenshot here:

The image

, , 1861 ... , 1 . , 1 8 6 1 , 8 6.

. , 1 , .

"" .

  • .
  • , ,
  • (, 1, , 1
  • , , .

.

1861
    Baked Beans
    dkjfdf skdfjsdlf
+1

All Articles