1
元素這裏是我的代碼摘錄Allignment上的JFrame
JButton browse,upload;
JPanel panel;
JLabel username,path;
final JTextField usernameText,pathText;
final JTextArea statusText;
InputWindow()
{
username = new JLabel();
username.setText("Username:");
usernameText = new JTextField(15);
startDate = new JLabel();
startDate.setText("Start Date :");
startDateText = new JPasswordField(15);
path = new JLabel();
path.setText("File Path :");
pathText = new JPasswordField(15);
browse=new JButton("Browse..");
upload=new JButton("Upload..");
statusText = new JTextArea(35, 35);
}
我應該如何將它添加到JFrame
或JPanel
看齊,在如下因素方面
- 行1 --->用戶名和的用戶名的文本
- 行2 --->的startDate和startDateText
- 行3 --->路徑,pathText,瀏覽和上傳
- 第4行---> statusText
我總是有時間對齊元素。請指導。
GroupLayout對您的問題聽起來很好:http://docs.oracle.com/javase/tutorial/uiswing/layout/group.html – Maroun
[您需要的全部內容 - 佈局經理的視覺指南](http:// docs .oracle.com/JavaSE的/教程/ uiswing /佈局/ visual.html)。通過結合這些幾乎所有的佈局是可能的。 – Dariusz
不要回滾編輯,我只是在改進你的編輯。 – Maroun