00c82cc5ee4f001d1594abca140770d0

来自「学生管理系统.对学生信息管理的一个应用软件!」· 代码 · 共 78 行

TXT
78
字号
import javax.swing.*;
import java.awt.*;
import javax.swing.border.*;
import java.awt.event.*;
class LoginWindow extends JFrame implements ItemListener,ActionListener
{  Box baseBox,boxV1,boxV2;
   Choice choice;
   TextField noText,passwordText;
   Label userLabel,noLabel,passwordLabel;
   Button loginButton,resetButton;
   LoginWindow(String s)
   {  super(s);
      userLabel=new Label("身份",Label.LEFT);
	  choice=new Choice();
      choice.add("学 生");
	  choice.add("管理人员");
	  choice.addItemListener(this);
	  noLabel=new Label("账号",Label.LEFT);
	  noText=new TextField(10);
	  passwordText=new TextField(10);
	  passwordLabel=new Label("密码",Label.LEFT);
      loginButton=new Button("登陆");
	  resetButton=new Button("重置");
	  
	  boxV1=Box.createVerticalBox();
	  boxV1.add(userLabel);
	  boxV1.add(Box.createVerticalStrut(8));
	  boxV1.add(noLabel);
	  boxV1.add(Box.createVerticalStrut(8));
	  boxV1.add(passwordLabel);
	  
	  
	  boxV2=Box.createVerticalBox();
	  boxV2.add(choice);
	  boxV2.add(Box.createVerticalStrut(8));
	  boxV2.add(noText);
	  boxV2.add(Box.createVerticalStrut(8));
	  boxV2.add(passwordText);
	  baseBox=Box.createHorizontalBox();
	  baseBox.add(boxV1);
	  baseBox.add(Box.createHorizontalStrut(10));
	  baseBox.add(boxV2);
	  setLayout(new FlowLayout());
	  add(baseBox);
	  boxV1.add(loginButton);
	  boxV2.add(resetButton);
	  
      noText.addActionListener(this);
      passwordText.addActionListener(this);
      loginButton.addActionListener(this);
      resetButton.addActionListener(this);
      
      this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	  setBounds(120,120,250,250);
	  setVisible(true);
	  validate();
   }
   public void itemStateChanged(ItemEvent e)
   {  String name=choice.getSelectedItem();
      int index=choice.getSelectedIndex();
      if(index==0)
      {   
    	  studentButton win=new studentButton("学生信息管理");
      }
      else  
      {
    	  Win3 wiin=new Win3("管理员信息界面");
      }
   }
    public void actionPerformed(ActionEvent e)
   {   
   }
}
  public class Login
{  public static void main(String args[])
   {  LoginWindow Win=new LoginWindow("学生信息管理系统") ;
   }
}

⌨️ 快捷键说明

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