package GMS;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import java.sql.*;
import java.net.URI;
public class GMS extends JFrame
{
String str1="";
String str2="";
JTextField t1=new JTextField();
JPasswordField pa1=new JPasswordField();
JTextField t2=new JTextField();
JPasswordField pa2=new JPasswordField();
JTextField t3=new JTextField();
JPasswordField pa3=new JPasswordField();
JTextField t4=new JTextField();
JPasswordField pa4=new JPasswordField();
JTextArea text6=new JTextArea ("");
int bool=0;
JTextField te1=new JTextField(); String st1="";
JTextField te2=new JTextField(); String st2="";
JTextField te3=new JTextField(); String st3="";
JTextField te4=new JTextField(); String st4="";
JTextField te5=new JTextField(); String st5="";
JTextField te6=new JTextField(); String st6="";
JTextField te7=new JTextField(); String st7="";
JTextField te8=new JTextField();
JTextField te9=new JTextField();
JTextField te10=new JTextField();
JTextField te11=new JTextField();
JTextField te12=new JTextField();
JTextField te13=new JTextField();
JTextField te14=new JTextField();
JTextField te15=new JTextField();
JTextField te16=new JTextField();
JTextField te17=new JTextField();
JTextField te18=new JTextField();
JTextField te21=new JTextField();
JTextField te22=new JTextField();
JTextField te23=new JTextField();
JTextField te24=new JTextField();
JTextField te25=new JTextField();
JTextField te26=new JTextField();
JTextField te27=new JTextField();
JTextField te28=new JTextField();
JTextField te29=new JTextField();
JTextField te30=new JTextField();
JTextField te31=new JTextField();
JTextField te32=new JTextField();
JTextField te33=new JTextField();
JTextField te34=new JTextField();
JTextField te35=new JTextField();
JTextField te36=new JTextField();
JTextField te37=new JTextField();
JTextField te38=new JTextField();
JTextField te39=new JTextField();
JTextField te40=new JTextField();
JTextField te41=new JTextField();
JTextField te42=new JTextField();
JTextField te43=new JTextField();
JTextField te44=new JTextField();
JTextField te45=new JTextField();
JTextField te46=new JTextField();
JTextField te47=new JTextField();
JTextField te48=new JTextField();
JTextField te49=new JTextField();
JTextField te50=new JTextField();
JPasswordField te19=new JPasswordField();
JPasswordField te20=new JPasswordField();
JTextArea text4=new JTextArea ("");
public GMS()
{
setTitle("餐厅管理系统");
initComponet();
setBounds(250,250,500,320);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
setVisible(true);
}
//初始化函数.
private void initComponet()
{
te1.setEditable(false);
te2.setEditable(false);
te3.setEditable(false);
te4.setEditable(false);
te5.setEditable(false);
te6.setEditable(false);
te7.setEditable(false);
te8.setEditable(false);
te9.setEditable(false);
te10.setEditable(false);
te11.setEditable(false);
te12.setEditable(false);
te13.setEditable(false);
te14.setEditable(false);
te15.setEditable(false);
te16.setEditable(false);
te17.setEditable(false);
te18.setEditable(false);
te19.setEditable(false);
te20.setEditable(false);
text4.setEditable(false);
text4.setForeground(Color.red);
text6.setEditable(false);
text6.setForeground(Color.red);
//创建所需要的功能模块,使用标签窗格.
JTabbedPane tp=new JTabbedPane();
JPanel p1=new JPanel();
//ImageIcon icon=new ImageIcon(this.getClass().getResource("photo.gif"));
JLabel lab=new JLabel("欢迎使用餐厅管理系统");
//lab.setIcon(icon);
p1.add(lab);
JPanel p2=new JPanel(new GridLayout(1,2));
JPanel p3=new JPanel(new GridLayout(1,2));
JPanel p4=new JPanel(new GridLayout(1,2));
JPanel p5=new JPanel(new GridLayout(1,2));
//JPanel p6=new JPanel();
tp.addTab("返回主页",p1);tp.addTab("会员管理",p2);tp.addTab("信息查询",p3);tp.addTab("外卖管理",p4);tp.addTab("厅内管理",p5);
Container c=this.getContentPane();
c.add(tp,BorderLayout.CENTER);
//创建面板p2用于用户登陆
//左边
JPanel p21=new JPanel(new GridLayout(2,1));
JPanel p211=new JPanel(new GridLayout(4,2));
JButton b1=new JButton("确定");///////////////////b1添加事件。
b1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
int sign=1;
str1=t1.getText();
str2=pa1.getText();
Login wang=new Login(sign,str1,str2);
bool=wang.returns();
if(bool==0)
{
te1.setEditable(false);
te2.setEditable(false);
te3.setEditable(false);
te4.setEditable(false);
te5.setEditable(false);
te6.setEditable(false);
}
else if(bool==1)
{
te1.setEditable(true);
te2.setEditable(true);
te3.setEditable(true);
te4.setEditable(true);
te5.setEditable(true);
te6.setEditable(true);
}
}
}
);
JPanel q1=new JPanel();
q1.add(b1);
JPanel q2=new JPanel();
JButton b2=new JButton("重置");//////////b2添加事件。
b2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
t1.setText("");
pa1.setText("");
te1.setEditable(false);
te2.setEditable(false);
te3.setEditable(false);
te4.setEditable(false);
te5.setEditable(false);
te6.setEditable(false);
te1.setText("");
te2.setText("");
te3.setText("");
te4.setText("");
te5.setText("");
te6.setText("");
}
}
);
q2.add(b2);
p211.add(new JLabel(" Name:"));
p211.add(t1);
p211.add(new JLabel(" Password:"));
p211.add(pa1);
p211.add(new JLabel(" "));
p211.add(new JLabel(" "));
p211.add(q1);
p211.add(q2);
//设置边框
JTextArea text1=new JTextArea ("注意事项!!!\n\r(1)用户登陆时,请输入正确的用户名及密码.\n\r(2)当输入的ID不在表中时,则插入新的记录,并且初始密码设为666666.\n\r(3)管理权限归管理员所有.\n\r");
text1.setEditable(false);
text1.setForeground(Color.red);
Border bor2=BorderFactory.createLineBorder(Color.DARK_GRAY);
text1.setBorder(bor2);
JScrollPane textScrollPane=new JScrollPane(text1);
Border bor1=BorderFactory.createLineBorder(Color.darkGray);
//p211.setBorder(bor1);
p21.add(p211);
p21.add(textScrollPane);
评论0