【发布时间】:2012-11-26 19:04:27
【问题描述】:
我有一个简单的 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));
【问题讨论】:
-
The Simulator在这台机器上出现左对齐,使用显示的代码(带导入)。好像是Locale依赖? -
这个L&F solution 可以帮助你。
标签: java swing user-interface alignment jframe