package aaaa;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.FlowLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class Paiban {
public static void main(String[] args) {
JFrame frame=new JFrame("布局");
frame.setBounds(300,200,300,300);
frame.setVisible(true);
JButton b1=new JButton("东");
JButton b2=new JButton("南");
JButton b3=new JButton("西");
JButton b4=new JButton("北");
JButton b5=new JButton("中");
/*frame.add(b1,BorderLayout.EAST);
frame.add(b2,BorderLayout.SOUTH);
frame.add(b3,BorderLayout.WEST);
frame.add(b4,BorderLayout.NORTH);
frame.add(b5,BorderLayout.CENTER);*/
frame.setLayout(null);
frame.setLayout(new FlowLayout());
/*b1.setLocation(10,50);
b1.setSize(50,50);
frame.add(b1);*/
frame.add(b1);
frame.add(b2);
frame.add(b3);
frame.add(b4);
frame.add(b5);
JLabel label=new JLabel("姓名");
frame.add(label);
JTextField tf=new JTextField(20);
frame.add(tf);
JLabel label2=new JLabel("密码");
frame.add(label2);
JPasswordField jp=new JPasswordField(20);
frame.add(jp);
JCheckBox cb=new JCheckBox();
frame.add(cb);
frame.add(new JLabel("南昌"));
JCheckBox cb1=new JCheckBox();
frame.add(cb1);
frame.add(new JLabel("北京"));
ButtonGroup group =new ButtonGroup();
JRadioButton rb1=new JRadioButton("男");
group.add(rb1);
frame.add(rb1);
JRadioButton rb2=new JRadioButton("女");
group.add(rb2);
frame.add(rb2);
JComboBox<String>cBox=new JComboBox<>();
cBox.addItem("北京");
cBox.addItem("南昌");
cBox.addItem("上海");
frame.add(cBox);
JTextArea jt=new JTextArea(10,20);
frame.add(jt);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
07-19
07-19
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交