虽然现在已经基本都不用java去写界面了,但是还是想去试试,不是情怀而是态度
public class Test {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setSize(250, 125);
JPanel panelFirst = new JPanel();
JPanel panelSecond = new JPanel();
panelFirst.setLayout(new GridLayout(2, 2));
JLabel userLabel = new JLabel("username");
JLabel passLabel = new JLabel("password");
JTextField userText = new JTextField();
JTextField passText = new JTextField();
panelFirst.add(userLabel);
panelFirst.add(userText);
panelFirst.add(passLabel);
panelFirst.add(passText);
panelSecond.setLayout(new FlowLayout());
Button reg = new Button("Register");
Button login = new Button("Login");
Button cancel = new Button("Cancel");
panelSecond.add(reg);
panelSecond.add(login);
panelSecond.add(cancel);
frame.setLayout(new BorderLayout());
frame.add(panelSecond, BorderLayout.SOUTH);
frame.add(panelFirst, BorderLayout.NORTH);
frame.setVisible(true);
}
}