📄 myframe.java~93~
字号:
package xue;
import java.awt.*;
import java.awt.event.*;
class MyFrame extends Frame implements ActionListener{
Label lb1=new Label("欢迎光临图书馆",Label.CENTER);
Label lb2=new Label("登陆界面",Label.CENTER);
Label lb3=new Label("输入学号");
Label lb4=new Label("Copyright:计算机系06级3班 薛伟伟",Label.LEFT);
TextField tf=new TextField("",10);
Button b1=new Button("确定");
public MyFrame(){
super("图书馆借阅系统");
setSize(600,400);
setLocation(200,200);
setBackground(Color.orange);
}
public void init1(){
Font f=new Font("楷体",Font.PLAIN,30);
Panel p1=new Panel();
Panel p2=new Panel();
setLayout(new GridLayout(4,1));
setFont(f);
add(lb1);
add(lb2);
add(lb3);
add(p1);
add(p2);
p1.add(lb3);
p1.add(tf);
p1.add(b1);
b1.addActionListener(this);
/*this.addKeyListener(new KeyAdapter(){
public void keyTyped(KeyEvent e) {
if(e.getSource().equals(KeyEvent.VK_ENTER)){
if(Long.valueOf(tf.getText()).longValue()>=6040021310l&&Long.valueOf(tf.getText()).longValue()<=6013110335l){
removeNotify();
new MyFrame2().init2();
}//if
else{
tf.setText("学号错误");
}
}//if
}
});*/
p2.setFont(new Font("楷体",Font.PLAIN,15));
p2.add(lb4);
}//init1
public void actionPerformed(ActionEvent e){
if((e.getSource()==b1)){
if(Long.valueOf(tf.getText()).longValue()>=6013110301l&&Long.valueOf(tf.getText()).longValue()<=6013110335l){
this.removeNotify();
new MyFrame2().init2();
}//if
else{
tf.setText("学号错误");
}
}//if
}
}
class MyFrame2 extends Frame implements ActionListener{
Label lb=new Label("欢迎借阅图书",Label.CENTER);
Label lb2=new Label("输入图书条码");
Label lb3=new Label("借阅成功!");
Label lb4=new Label("欢迎下次光临!");
Label lb5=new Label("再见!");
Button b2=new Button("查询");
Button b3=new Button("借阅");
Button b4=new Button("归还");
Button b5=new Button("OK");
TextField tf=new TextField();
Panel p1=new Panel();
Panel p2=new Panel();
Panel p3=new Panel();
Panel p4=new Panel();
Panel p5=new Panel();
Panel p6=new Panel();
MyFrame2(){
super("图书馆借阅系统");
setSize(600,400);
setLocation(200,200);
setBackground(Color.pink);
setLayout(new GridLayout(2,1,50,0));
}
public void init2(){
MyFrame2 mf=new MyFrame2();
mf.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
mf.add(p1);
mf.add(p2);
p1.setLayout(new GridLayout(2,1));
p1.add(p3);
p1.add(p4);
p2.setLayout(new GridLayout(2,1,10,0));
p2.add(p5);
p2.add(p6);
p5.setFont(new Font("楷体",Font.ITALIC,20));
p5.setLayout(new GridLayout(1,3,0,1000));
p5.add(lb2);
p5.add(tf);
p5.add(b5);
//p5.setVisible(false);
p6.setFont(new Font("楷体",Font.PLAIN,20));
p6.setLayout(new GridLayout(1,3,0,200));
p6.add(lb3);
p6.add(lb4);
p6.add(lb5);
//p6.setVisible(false);
p3.setFont(new Font("楷体",Font.PLAIN,30));
p3.add(lb);
p4.setFont(new Font("楷体",Font.PLAIN,30));
p4.setLayout(new GridLayout(1,3,0,300));
b2.setBackground(Color.blue);
b3.setBackground(Color.GREEN);
b4.setBackground(Color.orange);
p4.add(b2);
p4.add(b3);
p4.add(b4);
mf.setVisible(true);
}
public void actionPerformed(ActionEvent e){
char ch=e.getSource().toString().charAt(1);
switch (ch){
case '2':break;
case '3':{p5.setVisible(true);validate();break;}
case '4':break;
case '5':if(Long.valueOf(tf.getText()).longValue()>=1000001&&Long.valueOf(tf.getText()).longValue()<=1000020){
p6.setVisible(true);
}
else {
lb3.setText("对不起");
lb4.setText("借阅失败");
lb5.setText("请重试");
p6.setVisible(true);
}
break;
}//switch
}//actionPerformed
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -