1
我的Java程序正在創建給定JFrame窗口的多個實例,但是,jframe接縫可以在不同實例之間隨意更改大小(從小到大)。也就是說,假設我的程序創建了jframe的10個實例,那麼7可能具有正確的大小,但是3更大。這裏是我的代碼:Java swing JFrame更改實例之間的大小
public class ConvertionDialog extends JFrame{
private JComboBox<String> selection;
private JButton okButton;
public ConvertionDialog(){
super("Select Output Format");
this.setAlwaysOnTop(true);
this.setSize(new Dimension(500,55));
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.selection=new JComboBox<String>(GUI.getInstance().getRdfNotations());
this.okButton=new JButton("OK");
this.setLayout(new BorderLayout());
this.add(this.selection,BorderLayout.CENTER);
this.add(this.okButton,BorderLayout.EAST);
this.setVisible(true);
}
}
JFrame中使用簡單new ConvertionDialog();
我嘗試添加SwingUtilities.invokeLater(新的Runnable(){ \t公共無效的run(){ \t \t新ConvertionDialog(); \t} \t});但是,這並沒有解決問題。我在課堂上應該做些什麼(擴展JFrame)?謝謝。 –
@DanielValland:扔掉你的代碼。按照Camickr在答案中鏈接的[Oracle How To Make Frames教程](http://docs.oracle.com/javase/tutorial/uiswing/components/frame.html)。根據需要多次查看教程,直到完全瞭解如何製作JFrame。 –