我怎樣才能做到這一點在Java中,我不能設置大小,以我的文本框,我不知道究竟該怎麼辦,結果必然是:如何安排多個面板
這是我的代碼輸出I必須經過ID和第一文本框礦增加2個標籤和texfields:
class IU extends JFrame{
public IU(){
super("Tabela mysql");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400, 400);
getContentPane().setLayout(new BorderLayout());
JToolBar myBar=new JToolBar();
getContentPane().add(myBar,BorderLayout.NORTH);
JButton btnFirst=new JButton();
JButton btnPrevious=new JButton();
JButton btnNext=new JButton();
JButton btnLast=new JButton();
JButton btnAdd=new JButton();
JButton btnEdit=new JButton();
JButton btnDelete=new JButton();
JButton btnSearch=new JButton();
JButton btnUndo=new JButton();
JButton btnSave=new JButton();
JTextField txtAfis=new JTextField();
btnFirst.setIcon(new ImageIcon("MoveFirst.png"));
btnPrevious.setIcon(new ImageIcon("MovePrevious.png"));
btnNext.setIcon(new ImageIcon("MoveNext.png"));
btnLast.setIcon(new ImageIcon("MoveLast.png"));
btnAdd.setIcon(new ImageIcon("Add.png"));
btnEdit.setIcon(new ImageIcon("Edit.png"));
btnDelete.setIcon(new ImageIcon("Delete.png"));
btnSearch.setIcon(new ImageIcon("find.jpg"));
btnUndo.setIcon(new ImageIcon("undo.jpg"));
btnSave.setIcon(new ImageIcon("save.jpg"));
JPanel panel = new JPanel();
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
JTextField t = new JTextField();
JTextField t1 = new JTextField();
JTextField t2 = new JTextField();
t.setSize(100, 20);
t1.setBounds(20,10,70,20);
t2.setBounds(20,10,70,20);
JLabel label = new JLabel("Nume");
JLabel label2 = new JLabel("Prenume");
JLabel label3 = new JLabel("Id");
getContentPane().add(panel);
panel.add(label3);
panel.add(t, BorderLayout.EAST);
panel1.add(label2);
panel1.add(t1);
panel2.add(label);
panel2.add(t2);
myBar.add(btnFirst);
myBar.add(btnPrevious);
myBar.add(txtAfis);
myBar.add(btnNext);
myBar.add(btnLast);
myBar.add(btnAdd);
myBar.add(btnEdit);
myBar.add(btnDelete);
myBar.add(btnSearch);
myBar.add(btnSave);
myBar.add(btnUndo);
add(panel);
}
}
第一張圖像是我的輸出第二張圖片我想要做 –