0
我新在Java GUI,我花了3 小時試圖找出我做錯了或誤解了,我應該得到這樣的:GUI的Java文本和文本框相反顯示
但我的代碼中的文本顯示在文本字段後
textPanel = new JPanel();
textPanel.setLayout(new GridLayout(3,0));
fName = new JTextField(15) ;
textPanel.add(fName);
jlbName = new JLabel ("Firstname");
jlbName.setHorizontalAlignment(JLabel.RIGHT);
textPanel.add(jlbName);
lName = new JTextField(15) ;
textPanel.add(lName);
jlbName = new JLabel ("LastName");
jlbName.setHorizontalAlignment(JLabel.RIGHT);
textPanel.add(jlbName);
libNo = new JTextField(15) ;
textPanel.add(libNo);
libNo.setEditable(false);
jlbName = new JLabel ("Library Number");
jlbName.setHorizontalAlignment(JLabel.RIGHT);
textPanel.add(jlbName);
add(textPanel,BorderLayout.EAST);
JButton jbtN = new JButton("Add borrower");
add(jbtN ,BorderLayout.SOUTH);
使用適當的佈局。 – Rahul
你能更具體嗎? –