标签:返回 java als bounds ada 简单 box 窗口 ice
这是我自己写的一个java小应用程序窗口,是学习图形与界面是老师布置的一个作业,功能比较简单,其实,把程序整理的条理清晰,突然发现程序也蛮好写的。
package guotingting;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.event.*;
import java.awt.event.*;
//import java.util.Date;
import java.applet.Applet;
public class she extends Applet{
//public class she extends JFrame{
JButton b1=new JButton();
JButton b2=new JButton();
JButton b3=new JButton();
JLabel l1=new JLabel();
JLabel l2=new JLabel();
JLabel l3=new JLabel();
JLabel l4=new JLabel();
JLabel l5=new JLabel();
JLabel l6=new JLabel();
JLabel l7=new JLabel();
JLabel l8=new JLabel();
JLabel l9=new JLabel();
JLabel l10=new JLabel();
JLabel l11=new JLabel();
JLabel l12=new JLabel();
JLabel l13=new JLabel();
JTextField t1=new JTextField(" "
+ " ");
//JTextField t1=new JTextField();
JTextField t2=new JTextField();
JTextField t3=new JTextField();
JTextField t4=new JTextField();
JTextField t5=new JTextField();
JTextField t6=new JTextField();
JTextField t7=new JTextField();
JTextField t8=new JTextField();
JTextField t9=new JTextField();
JTextField t10=new JTextField();
JTextField t11=new JTextField();
JTextField t12=new JTextField();
JTextField t13=new JTextField();
JTextField t14=new JTextField();
JPanel p1=new JPanel();
JPanel p2=new JPanel();
JPanel p3=new JPanel();
JPanel p4=new JPanel();
JPanel p5=new JPanel();
JPanel p6=new JPanel();
JPanel p7=new JPanel();
JPanel p8=new JPanel();
JPanel p9=new JPanel();
JPanel p10=new JPanel();
public void init()
{
//super("个人信息表 Personal Information List");
setSize(500,660);
//Container cp=getContentPane();
this.setLayout(new BorderLayout());
//cp.setLayout(null);
this.add( p1,BorderLayout.NORTH);
p1.setBounds(10, 10, 460, 370);
//p1.setSize(960,370);
p1.setBackground(Color. pink);
p1.setBorder(new TitledBorder("个人信息:"));
//cp.add(p1);
p1.add(p5);
this.add( p2,BorderLayout.CENTER);
p2.setBounds(10, 380, 460, 100);
//p2.setSize(960,100);
p2.setBackground(Color.green);
p2.setBorder(new TitledBorder("兴趣爱好:"));
l13.setText("添加:");
p2.add(l13);
//cp.add(p2);
p2.add(p6);
this.add( p3,BorderLayout.SOUTH);
p3.setBackground(Color.yellow);
p3.setBounds(10,480,460,100);
//p3.setSize(960,100);
//cp.add(p3);
p3.add(p7);
p3.add(p8);
//this.add( p4,BorderLayout.CENTER);
//p4.setBackground(Color.red);
//p4.setBounds(10,580,960,100);
//p4.setSize(960,100);
//cp.add(p4);
//p4.add(p8);
p5.setLayout(new GridLayout(10,2));
l1.setText("姓名:");
p5.add(l1);
p5.add(t1);
l2.setText("性别:");
p5.add(l2);
CheckboxGroup cp1=new CheckboxGroup();
Checkbox c1=new Checkbox("男生",true,cp1);
p9.add(c1);
Checkbox c2=new Checkbox("女生",false,cp1);
p9.add(c2);
p5.add(p9);
l3.setText("年龄:");
p5.add(l3);
p5.add(t3);
l4.setText("名族:");
p5.add(l4);
p5.add(t4);
l5.setText("出生年份:");
p5.add(l5);
Choice ch1=new Choice();
ch1.add("1997");
ch1.add("1998");
ch1.add("1999");
ch1.add("2000");
p5.add(ch1);
l6.setText("政治面貌:");
p5.add(l6);
Choice ch2=new Choice();
ch2.add("团员");
ch2.add("党员");
p5.add(ch2);
l7.setText("身份证号:");
p5.add(l7);
p5.add(t7);
l8.setText("邮编:");
p5.add(l8);
p5.add(t8);
l9.setText("住址:");
p5.add(l9);
p5.add(t9);
l10.setText("联系电话:");
p5.add(l10);
p5.add(t10);
p6.setLayout(new GridLayout(3,1));
JCheckBox c3=new JCheckBox("阅读");
p10.add(c3);
JCheckBox c4=new JCheckBox("运动");
p10.add(c4);
JCheckBox c5=new JCheckBox("旅游");
p10.add(c5);
JCheckBox c6=new JCheckBox("书法绘画");
p10.add(c6);
JCheckBox c7=new JCheckBox("瑜伽");
p10.add(c7);
JCheckBox c8=new JCheckBox("摄影");
p10.add(c8);
p6.add(p10);
p6.add(t11);
p7.setLayout(new GridLayout(5,5,3,1));
b1.setLabel("提交");
p7.add(b1);
b2.setLabel("保存");
p7.add(b2);
b3.setLabel("返回");
p7.add(b3);
p7.add(b1);
p7.add(b2);
p7.add(b3);
b1.addMouseListener(new aa());
b2.addMouseListener(new aa());
b3.addMouseListener(new aa());
p8.setLayout(new GridLayout(1,0));
p8.add(l12);
//setVisible(true);
}
class aa extends MouseAdapter
{
public void mouseClicked(MouseEvent e)
{
l12.setText("OK!成功!");
}
}
//public static void main(String[] args)
//{
//new she();
//}
}
标签:返回 java als bounds ada 简单 box 窗口 ice
原文地址:http://www.cnblogs.com/guotingting/p/6131114.html