📄 xiaoshou.java
字号:
import javax.swing.*;
import java.awt.*;
import javax.swing.border.*;
import java.awt.event.*;
class B extends Frame implements ActionListener
{
Box baseBox,box1,box2;
Button Xsdl,b2;
Label l1,l2;
TextField t1,t2;
B(String s)
{ super(s);
box1=Box.createVerticalBox();
l1=new Label("用户名");
box1.add(l1);
box1.add(Box.createVerticalStrut(10));
l2=new Label("密码");
box1.add(l2);
box1.add(Box.createVerticalStrut(10));
Xsdl=new Button("确定");
Xsdl.addActionListener(this);
box1.add(Xsdl);
box1.add(Box.createVerticalStrut(10));
box2=Box.createVerticalBox();
t1=new TextField(12);
t1.addActionListener(this);
box2.add(t1);
box2.add(Box.createVerticalStrut(10));
t2=new TextField(12);
t2.setEchoChar('*');
t2.addActionListener(this);
box2.add(t2);
box2.add(Box.createVerticalStrut(10));
b2=new Button("退出");
b2.addActionListener(this);
box2.add(b2);
box2.add(Box.createVerticalStrut(10));
baseBox=Box.createHorizontalBox();
baseBox.add(box1);
baseBox.add(Box.createHorizontalStrut(10));
baseBox.add(box2);
setLayout(new FlowLayout());
add(baseBox);
setBackground(Color.cyan);
setBounds(200,200,250,180);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e)
{
setVisible(false);
}
});
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b2)
{
setVisible(false);
}
if(e.getSource()==Xsdl)
{String s1=t1. getText();
String s2=t2. getText();
if(s1.equals("computer")&&s2.equals("123456"))
{Pp c=new Pp("销售员界面");}
}
}
}
public class Xiaoshou
{
public static void main(String args[])
{
B caipiao=new B("销售员登陆系统");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -