⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 studentlistapp.java

📁 网络版的学生成绩管理系统
💻 JAVA
字号:
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.applet.*;
import java.rmi.activation.ActivationInstantiator;

import javax.swing.Action;

public class StudentListApp extends Applet 
{	
   Grid grdList;
   
   Panel pnlInput,btnPanel,top;
   Label msg;
   InputPanel ipInput;
 
   Button btnAdd,btnDel,btnEdit,btnSort;
   
	public void init() 
	{
	  pnlInput = new Panel( new BorderLayout() );
	  btnPanel= new Panel(new GridLayout(1,4));
	  msg=new Label("消息:");
	  msg.setForeground(Color.red);
	 
	  top=new Panel(new BorderLayout());
	  top.add(new Label("学生成绩管理系统."),"North");
	  top.add(new Label("鼠标单击IdNum项以选取条目,添加/修改在下方文本框输入."),"Center");
	  ipInput = new InputPanel(); 
	  top.add(ipInput,"South");
	  pnlInput.add(top,"North");
	  
	  pnlInput.add(msg,"Center");
	  btnAdd = new Button("Add");
	  addAction addL=new addAction();
	  btnAdd.addActionListener(addL);
	  btnDel = new Button("Del");
	  delAction delL=new delAction();
	  btnDel.addActionListener(delL);
	  btnEdit = new Button("Edit");
	  editAction editL=new editAction();
	  btnEdit.addActionListener(editL);
	  btnSort = new Button("Sort");
	  sortAction sortL= new sortAction();
	  btnSort.addActionListener(sortL);
	  btnPanel.add(btnAdd);
	  btnPanel.add(btnDel);
	  btnPanel.add(btnEdit);
	  btnPanel.add(btnSort);
	  
	  
	  pnlInput.add(btnPanel,"South"); 	  
	  add(pnlInput);
	  
	  grdList = new Grid();
	  rowClickAction rcL=new rowClickAction();
	  grdList.addrcListener(rcL);
	  add(grdList);
	}
	public  class addAction implements ActionListener{
		
		public void actionPerformed(ActionEvent e){
			try{
				grdList.addRow(ipInput.getData());
				msg.setText("消息:添加成功");
			}catch(IllegalArgumentException ie){
				msg.setText("消息:添加失败,"+ie.getMessage());
			}
		}
	}
	public  class delAction implements ActionListener{
		
		public void actionPerformed(ActionEvent e){
			String id=ipInput.getId();
			if(id.equals("")){
				msg.setText("请输入要修改的项目ID");
				return;
			}else{
				if(grdList.search(id)==-1){
					msg.setText("消息:未找到该项,删除失败!");
					return;
				}
			}
			grdList.delRow(id);
			msg.setText("消息:"+id+"项删除成功!");
		}
	}
	public  class sortAction implements ActionListener{
		
		public void actionPerformed(ActionEvent e){
				grdList.sortRow();
				msg.setText("消息:排序成功");
			
		}
	}
	public  class editAction implements ActionListener{
		
		public void actionPerformed(ActionEvent e){									
				String id=ipInput.getId();
				if(id.equals("")){
					msg.setText("请输入要修改的项目ID");
					return;
				}else{
					if(grdList.search(id)==-1){
						msg.setText("消息:未找到该项,修改失败!");
						return;
					}
				}
				try{										
						Student stu=ipInput.getData();
						grdList.editRow(stu);
						msg.setText("消息:编号"+id+"项修改成功");				
				}catch(Exception ie){
					msg.setText("消息:要修改"+id+"项,请将修改数据填写完整");
				}
				
			
		}
	}
	public class rowClickAction extends MouseAdapter{
		public void  mouseClicked(MouseEvent e){
			TextField txt=(TextField)e.getSource();
			
			String id=txt.getText();
			if(id.equals(""))
				return;
			msg.setText("选中了ID为"+id+"项");
			ipInput.setData(grdList.getRow(id));
			
		}
	}
	
}

⌨️ 快捷键说明

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