⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 telephone.txt

📁 JAVA常见的程序代码 有电话号码管理 有计算器 有飞机应用系统等等 欢迎观看
💻 TXT
📖 第 1 页 / 共 2 页
字号:
import java.awt.*;
import java.awt.event.*;
import java.util.*;
class p1 extends Panel{        //界面标题标签
	Label label1;
    Font f=new Font("宋体",Font.BOLD,20);
    p1(){
    	setLayout(new GridLayout(1,1));      //采用网格布局
        label1=new Label("学生电话号码管理",Label.CENTER);
        label1.setFont(f);
        add(label1);
    }
}
class p2 extends Panel{
    Label name,num;       //姓名学号标签
    TextField namefield,numfield;        //姓名学号文本框
    p2(){
        setLayout(new GridLayout(1,4));
        name=new Label("姓名:",Label.CENTER);
        num=new Label("编号:",Label.CENTER);
        namefield=new TextField(10);
        numfield=new TextField(10);
        Font f=new Font("宋体",Font.BOLD,20);
        name.setFont(f);
        num.setFont(f);
        add(name);
        add(namefield);
        add(num);
        add(numfield);
    }
}
class p3 extends Panel{
    Label address,telephone;
    TextField addressfield,telephonefield;
    p3(){
        setLayout(new GridLayout(1,4));
        address=new Label("家庭住址:",Label.CENTER);
        telephone=new Label("电话号码:",Label.CENTER);
        addressfield=new TextField(10);
        telephonefield=new TextField(10);
        Font f=new Font("宋体",Font.BOLD,20);
        address.setFont(f);
        telephone.setFont(f); 
        add(address);
        add(addressfield);
        add(telephone);
        add(telephonefield); 
    }
}
class p4 extends Panel{    //查找  
    Button btname,btnum; 
    p4(){
        setLayout(new GridLayout(1,2));
        btname=new Button("按用户姓名查询");
        btnum=new Button("按编号查询");
        add(btname);
        add(btnum);
    }
}
class p5 extends Panel{  //包含各种功能的类
    Button bmend,badd,bdelete,bclear,bexit;
    p5(){
        setLayout(new GridLayout(1,5));
        bmend=new Button("修改");
        badd=new Button("添加");
        bdelete=new Button("删除");
        bclear=new Button("清空");
        bexit=new Button("退出系统");
        add(bmend);
        add(badd);
        add(bdelete);
        add(bclear);
        add(bexit);
    }
}
class p6 extends Panel{   //快速寻找法
    Button bfirst,blast,bpassed,bnext; //分别为第一条,最后一条,
    p6(){                    //上一条,下一条记录
    	setLayout(new GridLayout(1,4));
    	bfirst=new Button("第一条");
    	blast=new Button("最后一条");
    	bpassed=new Button("上一条");
    	bnext=new Button("下一条");
    	add(bfirst);
    	add(blast);
    	add(bpassed);
    	add(bnext);
    }	
}
class p7 extends Panel{    //模糊查找类
	Label mfind;
	TextField mfindfield;
	Button btnmfind;
	p7(){
		setLayout(new GridLayout(1,3));
		mfind=new Label("模糊姓名:",Label.CENTER);
		mfindfield=new TextField(10);
		btnmfind=new Button("按姓名模糊查找");
		Font f=new Font("宋体",Font.BOLD,20);
		mfind.setFont(f);
		add(mfind);
		add(mfindfield);
		add(btnmfind);
	}
}
class p8 extends Panel{      //登陆界面设置
    Label title,no,password; //分别为标题,帐号,密码标签
    Label a1,a2,a3,a4,a5,a6,a7;
    Panel p11,p22,p33,p44,p55;
    TextField nofield,passwordfield; //帐号和密码文本框
    Button btn;         //确定按钮
    p8(){
        p11=new Panel();
        p22=new Panel();
        p33=new Panel();
        p44=new Panel();
        p55=new Panel();     //创建5块面板
        p11.setLayout(new GridLayout(1,1));
        p22.setLayout(new GridLayout(1,1));
        p33.setLayout(new GridLayout(1,4));
        p44.setLayout(new GridLayout(1,4));
        p55.setLayout(new GridLayout(1,3));
        a1=new Label("");
        a2=new Label("");
        a3=new Label("");
        a4=new Label("");
        a5=new Label("");
        a6=new Label("");
        a7=new Label("");
        title=new Label("欢迎来到电话管理系统",Label.CENTER);
        Font f=new Font("宋体",Font.BOLD+Font.ITALIC,30);    //设置字体
        title.setFont(f);
        no=new Label("输入帐号:",Label.CENTER);//居中显示
        password=new Label("输入密码:",Label.CENTER);
        Font f1=new Font("宋体",Font.BOLD,20);
        no.setFont(f1);
        password.setFont(f1);
        setBackground(Color.green); 
        btn=new Button("确定");
        btn.setFont(f1);
        nofield=new TextField(20);
        passwordfield=new TextField(15);
        passwordfield.setEchoChar('*');   //设置密码框回显
        title.setForeground(Color.red);
        nofield.setBackground(Color.cyan);//设置文本框背景色为青色
        passwordfield.setBackground(Color.cyan);
        nofield.setForeground(Color.red); //设置文本框前景色为红色
        passwordfield.setForeground(Color.red);
        no.setForeground(Color.blue);     //设置标签颜色
        no.setBackground(Color.pink);
        password.setForeground(Color.blue);
        password.setBackground(Color.pink);
        btn.setForeground(Color.blue);
        p11.add(title);            //第一块面板显示标题
        p22.add(a1);
        p33.add(a2);
        p33.add(no);
        p33.add(nofield);
        p33.add(a3);
        p44.add(a4);
        p44.add(password);
        p44.add(passwordfield);
        p44.add(a5);
        p55.add(a6);
        p55.add(btn);
        p55.add(a7);
        setLayout(new GridLayout(6,1)); //5行1列
        add(p11);
        add(p22);
        add(p33);
        add(p44);
        add(p55);
    }
}
class p9 extends Panel{
    p1 pn1=new p1();
    p2 pn2=new p2();
    p3 pn3=new p3();
    p4 pn4=new p4();
    p5 pn5=new p5();          //创建对象
    p6 pn6=new p6();
    p7 pn7=new p7();
    p9(){
        setLayout(new GridLayout(7,1));
        add(pn1);
        add(pn2);
        add(pn3);
        add(pn7);
        add(pn4);
        add(pn5);
        add(pn6);
    }
}
class student{     //记录同学的信息
    String name;
    String num;
    String address;
    String telephone;
    student(String name1,String num1,String address1,String telephone1){
        name=name1;
        num=num1;
        address=address1;
        telephone=telephone1;
    }
}
public class telephonenum{
    public static void main(String args[]){
    new zz();
    }
}
class zz extends Frame implements ActionListener{
    Vector v=new Vector();   //定义向量
    Button btn1;     //警告框确定按钮
    p8 pn8; 
    p9 pn9;
    Dialog d1;       //弹出警告标志
    CardLayout cc=new CardLayout(); //采用卡片式布局
    zz(){
        super("学生电话号码管理");
        pn8=new p8();
        pn9=new p9();
        setLayout(cc);
        add("first",pn8);
        add("next",pn9);
        btn1=new Button("确定");
        pn9.pn1.label1.setBackground(Color.pink);
        pn9.pn1.label1.setForeground(Color.blue);  //标题前背景色
        pn9.pn2.name.setBackground(Color.gray);
        pn9.pn2.name.setForeground(Color.orange); //姓名前背景色
        pn9.pn2.num.setBackground(Color.gray);
        pn9.pn2.num.setForeground(Color.orange);  //编号前背景色
        pn9.pn3.address.setBackground(Color.gray);
        pn9.pn3.address.setForeground(Color.orange);//地址前背景色
        pn9.pn3.telephone.setBackground(Color.gray);
        pn9.pn3.telephone.setForeground(Color.orange);//电话号码前背景色
        pn9.pn2.namefield.setForeground(Color.red);
        pn9.pn2.namefield.setBackground(Color.cyan);//姓名文本框前背景色
        pn9.pn2.numfield.setForeground(Color.red);
        pn9.pn2.numfield.setBackground(Color.cyan);//编号文本框前背景色
        pn9.pn3.addressfield.setForeground(Color.red);
        pn9.pn3.addressfield.setBackground(Color.cyan);//地址文本框前背景色
        pn9.pn3.telephonefield.setForeground(Color.red);
        pn9.pn3.telephonefield.setBackground(Color.cyan);//电话文本框前背景色
        pn9.pn7.mfind.setForeground(Color.orange);  
        pn9.pn7.mfind.setBackground(Color.gray); //模糊查询标签前背景色
        pn9.pn7.mfindfield.setForeground(Color.red);
        pn9.pn7.mfindfield.setBackground(Color.cyan);//模糊查询文本框前背景色
        pn9.pn4.btname.addActionListener(this);  //注册事件监听者
        pn9.pn4.btnum.addActionListener(this);
        pn9.pn5.bmend.addActionListener(this);
        pn9.pn5.badd.addActionListener(this);
        pn9.pn5.bdelete.addActionListener(this);
        pn9.pn5.bclear.addActionListener(this);
        pn9.pn5.bexit.addActionListener(this);
        pn9.pn6.bfirst.addActionListener(this);
        pn9.pn6.blast.addActionListener(this);
        pn9.pn6.bpassed.addActionListener(this);
        pn9.pn6.bnext.addActionListener(this);
        pn9.pn7.btnmfind.addActionListener(this);
        pn8.btn.addActionListener(this);
        btn1.addActionListener(this);
        setSize(600,300);
        show();          
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -