Reputation: 1188
For displaying information on a Java Swing GUI I use a mixture of JLabel
components and JTextPanes
.
As you can see in the following image, all labels are JLabels
except for the one in the bottom right corner which is marked red and yellow. This one's a JTextPane
, cause I don't know the text length before rendering and it has to wrap (which is not working in a JLabel
, right?).
The left column is aligned right and has a right-margin of 5, the right column is aligned left with zero margin.
In Eclipse WindowBuilder and on Windows 7 rendering, the JTextPane
obviously has a small padding which I can't remove.
Surprisingly, this padding isn't shown on my Mac (Mountain Lion) and the JTextPane
is aligned perfectly well.
Is there any way to achieve the same aligned look on Windows and on Mac? And why on earth does the JTextPane
component has this annoying padding on windows?
Upvotes: 4
Views: 1501
Reputation: 57381
Use textPane.getMargin()/setMargin()
but actually it's defined by L&F
Upvotes: 7