教师课程地点申请简单操作界面

代码如下:

package shangke.diwuzhou;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.*;


import java.math.*;
import java.util.Random;
public  class xinkechengtianjia extends JFrame implements ActionListener{
    private JLabel user,password,check,user0,password0,didian;
    private JTextField word1,word2,word3,word5,word6;
    private JPasswordField word4;
    private Button login,register,checkbutton,yes;
    private JFrame background1,background2;
     static String num;
     static public String zhanghao[]=new String[10],mima[]=new String[10],weizhi[]=new String[10],laoshi[]=new String[10],difang[]=new String[10];
     static int flag=1;
     static int flag1=1;
     static int flag2=1;
     static int flag3=1;
     static int sum=0;
     static String jiaoshi[]=new String[4];
     static
     {
         jiaoshi[0]="一教";
          jiaoshi[1]="二教";
          jiaoshi[2]="三教";
          jiaoshi[3]="基教";
     }
      
     public boolean what=true;

    public static void main(String[] args) {
        xinkechengtianjia.mima[0]="王建民";
        xinkechengtianjia.mima[1]="刘立嘉";
        xinkechengtianjia.mima[2]="刘丹";
        xinkechengtianjia.mima[3]="王辉";
        xinkechengtianjia.mima[4]="杨子光";
        xinkechengtianjia deng= new xinkechengtianjia();
        deng.showTime();
        /*for(;;)
        {
            deng.showTime();
            if(!deng.what)break;
        }*/
        
        
    }


    
    public void showTime()
    {
        JFrame background2=new JFrame();
        background2.setTitle("注册界面");
        background2.setLayout(null);//居中
        
        //账号设置
        user0 = new JLabel("课程名称");
        word3 = new JTextField("",15);
        user0.setBounds(100, 13, 60, 40);
        word3.setBounds(160, 20, 120, 25);
        word3.addActionListener(this);
        background2.add(user0);
        background2.add(word3);
        //密码设置
        password0 = new JLabel("任课老师");
        word5 =new JTextField("",15);
        password0.setBounds(100, 53, 60, 40);
        word5.setBounds(160, 60, 120, 25);
        background2.add(password0);
        background2.add(word5);
        //地点
        didian = new JLabel("任课地点");
        word6 =new JTextField("",15);
        didian.setBounds(100, 93, 60, 40);
        word6.setBounds(160, 100, 120, 25);
        background2.add(didian);
        background2.add(word6);
        //确定按钮
        yes = new Button("注册");
        yes.setBackground(Color.orange);
        yes.setBounds(75, 140, 240, 40);
        yes.addActionListener(this);
        yes.addMouseListener(new MouseAdapter()
        {
            public void mouseClicked(MouseEvent e)
            {
                if (e.getButton() == MouseEvent.BUTTON1)
                    {
                    if(!word3.getText().equals("")&&!word5.getText().equals("")&&!word6.getText().equals("")) 
                    {
                        flag=1;
                        flag1=1;
                        flag2=0;
                        flag3=0;
                        for(int j=0;j)
                        {
                            if(zhanghao[j].contentEquals(word3.getText())&&laoshi[j].contentEquals(word5.getText())&&difang[j].contentEquals(word6.getText()))flag1=0;
                            
                        }
                        for(int j=0;j<5;j++)
                        {
                            if(mima[j].contentEquals(word5.getText()))flag2=1;
                        }
                        for(int j=0;j<4;j++)
                        {
                            if(jiaoshi[j].contentEquals(""+word6.getText().charAt(0)+word6.getText().charAt(1)))flag3=1;
                        }
                        if(flag1==0||flag2==0||flag3==0)flag=0;
                        if(flag==1)
                        {
                            zhanghao[sum]=word3.getText();
                            laoshi[sum]=word5.getText();
                            difang[sum]=word6.getText();
                            sum++;
                            JOptionPane.showMessageDialog(null, "注册成功!");
                            background2.setVisible(false);
                            showtime2();
                        }
                        else if(flag1==0)
                        {
                            word3.setText("");
                            word5.setText("");
                            word6.setText("");
                            JOptionPane.showMessageDialog(null, "该课程已存在!");
                        }
                        else if(flag2==0)
                        {
                            word3.setText("");
                            word5.setText("");
                            word6.setText("");
                            JOptionPane.showMessageDialog(null, "该老师不存在存在!");
                        }
                        else if(flag3==0)
                        {
                            word3.setText("");
                            word5.setText("");
                            word6.setText("");
                            JOptionPane.showMessageDialog(null, "该教室不存在存在!");
                        }
                    }
                    else 
                    {
                        word3.setText("");
                        word5.setText("");
                        JOptionPane.showMessageDialog(null, "请输入完整信息!");
                    }
                    }
            }
            
        });
        background2.add(yes);
        background2.setVisible(true);
        background2.setSize(400, 250);
        background2.setLocationRelativeTo(null);
        background2.setResizable(false);
    }
    public void showtime2()
    {
        //总的框
        background1 = new JFrame();
        background1.setTitle("登录界面");
        background1.setLayout(null);//居中
        
        user =new JLabel("是否继续注册");
        user.setBounds(100, 13, 160, 40);
        background1.add(user);
        //设置选择按钮
        login = new Button("是");
        login.setBackground(Color.orange);
        login.setBounds(50, 100, 200, 40);
        login.addActionListener(this);
        background1.add(login);
        
        register = new Button("否");
        register.setBackground(Color.orange);
        register.setBounds(50, 150, 200, 40);
        register.addActionListener(this);
        background1.add(register);
        
        background1.setVisible(true);
        background1.setSize(300, 250);
        background1.setLocationRelativeTo(null);
        background1.setResizable(false);
        background1.setDefaultCloseOperation(3);
    }
    public void actionPerformed(ActionEvent e)
    {
        if(e.getActionCommand()=="是")
            {
            background1.setVisible(false);
            showTime();
            }
        else
        {
            background1.setVisible(false);
        }
    }
    
}

 

截图如下:

教师课程地点申请简单操作界面_第1张图片教师课程地点申请简单操作界面_第2张图片

 

程序要求:

上课老师必须是所要求的几位老师,上课地点必须带有一教,二教,三教,基教等;

你可能感兴趣的:(教师课程地点申请简单操作界面)