![]()
import javax.swing.* ;
import java.awt.* ;
class myTest extends JFrame{
public myTest(){
this.setSize(400,400);
this.setLocation(100,100) ;
this.setTitle("zhuopeng") ;
Container c = this.getContentPane() ;
c.setLayout(new FlowLayout()) ;
//字体颜色
Font f1 = new Font("楷书",Font.PLAIN,20) ;
JLabel name = new JLabel("账号") ;
name.setFont(f1) ;
name.setForeground(Color.BLUE) ;
c.add(name);
JTextField nameSpace = new JTextField(10) ;
c.add(nameSpace) ;
c.add(new Label("密码:")) ;
JTextField password = new JTextField(10) ;
c.add(password) ;
JButton login = new JButton("登录") ;
c.add(login) ;
// 多选
JPanel p1 = new JPanel() ;
JCheckBox c1 = new JCheckBox("记住密码") ;
JCheckBox c2 = new JCheckBox("自动登录") ;
p1.add(c1) ;
p1.add(c2) ;
c.add(p1) ;
//单选
JPanel p2 = new JPanel () ;
JRadioButton rb1 = new JRadioButton("男") ;
JRadioButton rb2 = new JRadioButton("女") ;
p2.add(rb1) ;
p2.add(rb2) ;
c.add(p2) ;
ButtonGroup bg1 = new ButtonGroup();
bg1.add(rb1);
bg1.add(rb2);
//选择
JComboBox cb1 = new JComboBox() ;
cb1.addItem("计科1班") ;
cb1.addItem("计科2班") ;
cb1.addItem("计科3班") ;
c.add(cb1) ;
//多行文本
TextArea ta = new TextArea(10,40) ;
c.add(ta) ;
this.setVisible(true) ;
}
}
public class Demo {
public static void main(String [] args){
myTest a = new myTest() ;
}
}