我有一个简单的 JFrame 窗口,它的标题一直向右浮动(虽然是用英文写的)。住在中东但使用英文版的 Windows 7。正确对齐标题文本和标题栏左端的正确方法是什么?
imports...
public class MainWindow extends JFrame {
private JPanel contentPane;
private final String arr[] = {"1","2","3","4","5","6","7","8","9","10"};
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
MainWindow frame = new MainWindow("The Simulator");
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public MainWindow(String title) {
super(title);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 582, 435);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
JButton btnRandom = new JButton("Generate new random DCSP");
contentPane.add(btnRandom);
JButton btnManual = new JButton("Generate new manual DCSP");
contentPane.add(btnManual);
}
}
没有帮助使用
frame.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
或者
frame.applyComponentOrientation(ComponentOrientation.getOrientation(Locale.US));