FULL PRODUCT VERSION :
openjdk version " 1.8.0-internal "
OpenJDK Runtime Environment (build 1.8.0-internal-strunk_2013_04_24_12_17-b00)
OpenJDK 64-Bit Server VM (build 25.0-b28, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Mac OSX 10.8.2
A DESCRIPTION OF THE PROBLEM :
The preferred size of JLabels is incorrect when displayed on a Retina display, when using a non-default font size.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
To reproduce, execute the code given below on a retina and a non-retina display. On a retina display the label text is cut off.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JLabel should not be cut off on retina displays.
ACTUAL -
On a retina display the label text is cut off.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Font;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.WindowConstants;
public class JLabelDemo {
public static void main(String[] args) {
JFrame frame = new JFrame( " JLabel Demo " );
Container contentPane = frame.getContentPane();
contentPane.setLayout(new FlowLayout());
final JLabel label = new JLabel(
" This is a monstrous mmmmmega label text which will not fit " );
label.setBorder(BorderFactory.createEtchedBorder());
label.setFont(new Font(label.getFont().getName(), label.getFont().getStyle(), 11));
contentPane.add(label);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Increase the preferred width by a few pixels so JLabels are rendered large enough.