我有簡單的JFrame窗口,它的標題保持向右(儘管用英文寫成)。 生活在中東,而且使用的是Windows 7 的英文版本這將是對準正確的標題文字和 標題欄左端的正確方法是什麼?JFrame標題不能正確對齊
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));
'的Simulator'似乎離開了這臺機器上對齊,用圖示(含進口)的代碼,這似乎是['Locale'(HTTP://文檔.oracle.com/javase/7/docs/api/java/util/Locale.html)依賴? –
這[L&F解決方案](http://stackoverflow.com/questions/6455831/set-jframe-or從右到左的定向)可以幫助你。 – Reimeus