I am experiencing a few problems with the swing borders after upgrading from Java 1.7 to Java 1.8:
On all my buttons, I need a solid background-color and a solid border, so I defined that via UIManager. On Java 1.7 and previous versions everything looks good, but on Java 1.8 the border is all messed up. Also the RadioButton looks very strange and jaggy. CheckBoxes also seem to have a problem.
For demonstration I created a short sample with a few components:
import java.awt.Color;
import java.awt.FlowLayout;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.JToggleButton;
import javax.swing.UIManager;
public class CompDemo extends JFrame
{
public CompDemo()
{
setLayout(new FlowLayout());
add(new JButton("button"));
add(new JTextField("txt"));
add(new JComboBox<String>());
add(new JRadioButton("radio"));
add(new JToggleButton("toggle"));
add(new JCheckBox("check"));
pack();
setVisible(true);
}
public static void main(String[] args)
{
UIManager.put("Button.background", Color.LIGHT_GRAY);
UIManager.put("Button.border", BorderFactory.createCompoundBorder(BorderFactory
.createLineBorder(Color.RED), BorderFactory.createLineBorder(Color.CYAN)));
new CompDemo();
}
}
Here you can see the output with different JDK versions (scaled up to 200 percent without anti aliasing): The first one is Java 7u60 and displays everything correct. On the second picture I circled the differences. The third one is with Java 8u11 and as you can see the borders are quite messed up (and the dropdown arrow looks strange as well).
I used a cyan LineBorder inside a red LineBorder so you can see the problem more clearly.
My OS is Windows 8 x64, if it matters.
Can anyone tell me why this looks so different on Java 8? Did I miss something or did they really mess up the borders in Java 1.8? Do I have to file a bug report issue? Or are there just a few adjustments to be made to make it look fine again?
Thanks, gc