默认布局管理器是流式布局(FlowLayout) 按钮的建立: jb1=new JButton("香蕉") 面板的建立:jp1=new JPanel(); 设置JFrame的标题:this.setTitle("往常"); 设置JFrame大小:this.setSize(300,200); 禁止用户改变窗体大小:this.setResizable(false); 设置JFrame显示的位置:this.setLocation(200,300); 默认关闭:this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 显示JFram:this.setVisible(true); 标注建立: jlb1=new JLabel("用户名"); jlb1=new JLabel(“标注”,new ImageIcon(“image/mm.gif”),JLabel.left) jlb1=new JLabel(“qq密码”,JLabel.LEFT) 将前景色设置为高亮红 jbls.Foreground(Color.red) 需要对每个jbls进行监听 jbls.addMouseListener(this); jtf1=newJTextField(10); jpf1=newJPasswordField(10); 给窗体加上小图标如qq企鹅 this.setIconImage((newImageIcon("image/touxiang.gif")).getImage()) 下拉框组件(JComboBox):String []jg={"北京","上海","天津","重庆"}; jcb=newJComboBox(jg); 列表组件(JList):String[]dd={"青岛","秦皇岛","黄山","香山"}; jlist=new JList(dd) jlist.setVisibleRowCount(2);//设置你希望显示多少个 jsp=newJScrollPane(jlist); 复选框组件(JCheckBox)单选框组件(JRadioButton),同一组单选按钮必须先创建ButtonGroup,然后把单选框组件放入到ButtonGroup //创建一个选项卡窗口jtp=new JTabbedPane(); jtp.add("QQ号码",jp2);jp3 =new JPanel(); jtp.add("手机号码",jp3);jp4 =new JPanel(); jtp.add("电子邮件",jp4);