after upgrading from Java 10 to Java 11 the text in a JTextField is not vertically centered anymore. Is there something I can do to get back the old behaviour? Following code run with JDK 10 (upper window in image) and JDK 11.0.8 for Windows (lower window in image) reproduces the problem.
import java.awt.Color;
import java.awt.Font;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class JTextFieldTest{
public static void main(String[] args) {
JTextField textInputField = new JTextField(20);
textInputField.setBackground(Color.ORANGE);
textInputField.setFont(new Font("Calibri", Font.BOLD, 30));
textInputField.setSize(textInputField.getPreferredSize());
textInputField.setVisible(true);
JFrame frame = new JFrame();
frame.add(textInputField);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Output of code with JDK 10 and 11: