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

📄 chaxun.java

📁 用JAVA编写的综合测评系统毕业设计
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

import java.text.DecimalFormat; //导入需要的类
import java.applet.Applet;  
import java.awt.Panel;
import java.awt.Label;
import java.awt.TextArea;
import java.awt.TextField;
import java.awt.Checkbox;
import java.awt.Button;
import java.awt.Choice;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.CardLayout;
import java.awt.CheckboxGroup;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.util.ArrayList;
import java.util.Vector;
import java.net.Socket;
import java.net.InetAddress;
import java.io.DataOutputStream;
import java.io.DataInputStream;
import javax.swing.JPanel;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.BorderFactory;
import javax.swing.table.AbstractTableModel;
import javax.swing.JScrollPane;


public class Chaxun extends Applet  implements ActionListener,ItemListener
{
	private Checkbox jingque=new Checkbox("精确查询");
	private Checkbox mohu=new Checkbox("模糊查询");
	private TextField xuehao=new TextField();
	private Checkbox  yewudayu=new Checkbox(">=");
	private Checkbox  yewuxiaoyu=new Checkbox("<");
	private Checkbox  zonghedayu=new Checkbox(">=");
	private Checkbox  zonghexiaoyu=new Checkbox("<");
	private Inputfloat yewu=new Inputfloat();
	private Inputfloat zonghe=new Inputfloat();
	private Button butchaxun=new Button(".      查    询      .");
	private Button butbilixianshi=new Button("成绩比例显示");
	private JPanel jpchaxun=new JPanel();    //查询界面的面板
	private JPanel jpjingquexianshi=new  JPanel();     //精确查询结果显示界面面板
	private JPanel jpmohuxiashi=new JPanel();
	private JPanel jpbilixianshi=new JPanel();
	private Button butqueding=new Button("         确定        ");
	private Button butmohuqueding=new Button("         确定        ");
	private Button butbiliqueding=new Button("         确定        ");
    
	private CardLayout cardlayout=new CardLayout();
	private TextArea jingquexianshi=new TextArea();
	
	private Bilitu left=null;
	private Bilitu right=null;


	
	private Vector vector=new Vector();
	private JTable jtable=null;
	private AbstractTableModel tm=null;
	private JScrollPane  jsp=null;
	private String[] title={"学号","姓名","政治思想素质","业务学习","智能素质","体育素质","综合测评得分"};
	
	private String sql=null;
	private String jieguo=null;
	
	public void init()
	{

		JPanel jp1=new JPanel();  //事例化并初始化每个面板
		JPanel jp2=new JPanel();
		JPanel jp3=new JPanel();
		jp1.setBorder(BorderFactory.createTitledBorder("选择查询方式"));
		jp1.setLayout(new GridLayout(2,1));
		jp1.setBackground(Color.white);
		jp1.setFont(new Font("宋体",Font.PLAIN,15) );
		jp2.setBorder(BorderFactory.createTitledBorder("请输入精确查询条件:"));
		jp2.setLayout(new GridLayout(2,1));
		jp2.setBackground(Color.white);
		jp2.setFont(new Font("宋体",Font.PLAIN,15) );
		jp3.setBorder(BorderFactory.createTitledBorder("请输入模糊查询条件:"));
		jp3.setLayout(new GridLayout(2,1));
		jp3.setBackground(Color.white);
		this.jpchaxun.setBackground(Color.white);
		this.jpjingquexianshi.setLayout(new BorderLayout());
		JPanel p3=new JPanel();
		p3.add(this.butqueding);
		this.jpjingquexianshi.add(p3,"South");
		this.jpmohuxiashi.setBackground(Color.white);
		this.jpmohuxiashi.setLayout(new BorderLayout());
		JPanel p4=new JPanel();
		this.butmohuqueding.addActionListener(this);
		p4.add(this.butmohuqueding);
		this.jpmohuxiashi.add(p4,"South");
	    this.setLayout(this.cardlayout);
		CheckboxGroup cg1=new CheckboxGroup();
	    CheckboxGroup cg2=new CheckboxGroup();
		CheckboxGroup cg3=new CheckboxGroup();
		this.jingque.setCheckboxGroup(cg1);
		this.jingque.addItemListener(this);
		this.mohu.setCheckboxGroup(cg1);
		this.mohu.addItemListener(this);
		this.jingque.setState(true);
		
		this.xuehao.setEnabled(true);
		this.xuehao.requestFocus();
		this.yewudayu.setEnabled(false);
		this.yewuxiaoyu.setEnabled(false);
		this.zonghedayu.setEnabled(false);
		this.zonghexiaoyu.setEnabled(false);
		this.yewu.setEnabled(false);
		this.zonghe.setEnabled(false);
		    
		this.yewudayu.setCheckboxGroup(cg2);
		this.yewuxiaoyu.setCheckboxGroup(cg2);
		this.yewudayu.setState(true);
		this.zonghedayu.setCheckboxGroup(cg3);
		this.zonghexiaoyu.setCheckboxGroup(cg3);
		this.zonghedayu.setState(true);
		this.butchaxun.addActionListener(this);
		this.butqueding.addActionListener(this);
		jp1.add(this.jingque);
		jp1.add(this.mohu);
		jp2.add(new Label("学号:"));
		jp2.add(this.xuehao);
		JPanel p1=new JPanel();
		JPanel p2=new JPanel();
		p1.setBackground(Color.white);
		p1.setFont(new Font("宋体",Font.PLAIN,15) );
		p2.setBackground(Color.white);
		p2.setFont(new Font("宋体",Font.PLAIN,15) );
		p1.add(new Label("业务学习成绩"));
		p1.add(this.yewudayu);
		p1.add(this.yewuxiaoyu);
		p1.add(this.yewu);
		p2.add(new Label("综合测评成绩"));
		p2.add(this.zonghedayu);
		p2.add(this.zonghexiaoyu);
		p2.add(this.zonghe);
	    jp3.add(p1);
	    jp3.add(p2);
	    JPanel jp4=new JPanel();
	    jp4.setBackground(Color.white);
	    jp4.add(this.butchaxun);
	    this.butbilixianshi.addActionListener(this);
	    jp4.add(this.butbilixianshi);
	    JPanel jp5=new JPanel();
	    jp5.setBackground(Color.white);
	    jp5.setLayout(new GridLayout(4,1));

	    jp5.add(jp1);
	    jp5.add(jp2);
	    jp5.add(jp3);
	    jp5.add(jp4);
	    this.jpchaxun.add(jp5);
	    this.add("chaxun",this.jpchaxun);
	    this.jingquexianshi.setFont(new Font("宋体",Font.PLAIN,15) );
	    this.jpjingquexianshi.add(this.jingquexianshi);
	    this.add("jingquexianshi",this.jpjingquexianshi);
	    
	    
	    this.tm=new AbstractTableModel()
	    {
	      public int getColumnCount() { return title.length; }
          public int getRowCount() { return vector.size();}
          public Object getValueAt(int row, int col)
          {
          	if(!vector.isEmpty())
          	{
          		return ((Vector)vector.elementAt(row)).elementAt(col);
          	}
          	else
          	 return null;
          }
          
          public String getColumnName(int column)
          {
          	return title[column];//置表格列
          }

	    	
	    };
	    
	    this.jtable=new JTable(tm);
	    this.jtable.setToolTipText("显示全部查询结果");
		//this.jtable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
		this.jtable.setCellSelectionEnabled(false);
		this.jtable.setShowVerticalLines(true);
		this.jtable.setShowHorizontalLines(true);
		//this.jtable.setFont(new Font("宋体",Font.PLAIN,50));
	    this.jsp=new JScrollPane(this.jtable);
	    //this.jsp.setFont(new Font("宋体",Font.PLAIN,15));
	    
	    this.jpmohuxiashi.add(this.jsp);
	    this.add(this.jpmohuxiashi,"mohuxianshi");
	    
	    
	    
	    String[] a={"综合测评成绩比例图:","        综合测评成绩<80","80=<综合测评成绩<85","85=<综合测评成绩<90","        综合测评成绩>=90"};
	    left=new Bilitu(a);
	    String[] b={"业务学习成绩比例图:","        业务学习成绩<40","40=<业务学习成绩<45","45=<业务学习成绩<50","        业务学习成绩>=50"};
	    right=new Bilitu(b);
	    this.jpbilixianshi.setLayout(new BorderLayout());
	    Panel bilimianban=new Panel();
	    bilimianban.setLayout(new GridLayout(1,2));
	    bilimianban.add(this.left);
	    bilimianban.add(this.right);
	    this.jpbilixianshi.add(bilimianban);
	    Panel biliquedingmianban=new Panel();
	    biliquedingmianban.add(this.butbiliqueding);
	    this.jpbilixianshi.add(biliquedingmianban,"South");
	    this.butbiliqueding.addActionListener(this);
	    this.add(this.jpbilixianshi,"bilitu");
	    
	    

	}
	
	
	
	public void itemStateChanged(ItemEvent e)     //实现接口,实现精确查询与模糊查询之间的转换
	{
		if(((Checkbox)e.getSource()).equals(this.jingque))
		{
			this.xuehao.setEnabled(true);
			this.xuehao.requestFocus();
		    this.yewudayu.setEnabled(false);
		    this.yewuxiaoyu.setEnabled(false);
		    this.zonghedayu.setEnabled(false);
		    this.zonghexiaoyu.setEnabled(false);
		    this.yewu.setEnabled(false);
		    this.zonghe.setEnabled(false);
	     }
		else
		{
			this.xuehao.setEnabled(false);
			this.yewudayu.setEnabled(true);
		    this.yewuxiaoyu.setEnabled(true);
		    this.zonghedayu.setEnabled(true);
		    this.zonghexiaoyu.setEnabled(true);
		    this.yewu.setEnabled(true);
		    this.zonghe.setEnabled(true);
			
		}
		
	}
	
	
	
	public void actionPerformed(ActionEvent e)     //按钮事件
	{
		Socket socket=null;
		DataInputStream datain=null;
		DataOutputStream dataout=null;
		
		if(((Button)e.getSource()).equals(this.butchaxun))  //点击了查询按钮,进行查询   
		{
			if(this.jingque.getState())
			{
				this.sql=this.getjingquechaxun();
				if(sql.length()!=0)
				{
					try
					{
						socket=new Socket(InetAddress.getByName(getCodeBase().getHost()),3636) ;
					    datain=new DataInputStream(socket.getInputStream());
					    dataout=new DataOutputStream(socket.getOutputStream());
					    sql="精确查询:"+sql;
					    dataout.writeUTF(sql);
					    this.jieguo=datain.readUTF();
					    System.out.println(jieguo);
					    if(this.jieguo.trim().equals("无结果"))
					    {
					    	JOptionPane.showMessageDialog(this,"没有你要查询的信息,请确认学号无误!");
					    }
					    else
					    {

					    	this.cardlayout.show(this,"jingquexianshi");
					    	String[] temp=this.jieguo.split(",");
					    	this.jingquexianshi.setText("");
					    	this.jingquexianshi.append("\n");
					    	this.jingquexianshi.append("\n      学号:" + temp[0] + "\n");
					    	this.jingquexianshi.append("\n      姓名:" + temp[1] + "\n");
					    	this.jingquexianshi.append("\n      政治思想素质得分:" + temp[2] + "\n");
					    	this.jingquexianshi.append("\n      业务学习得分:" + temp[3] + "\n");
					    	this.jingquexianshi.append("\n      智能素质得分:" + temp[4] + "\n");
					    	this.jingquexianshi.append("\n      体育素质得分:" + temp[5] + "\n");
					    	this.jingquexianshi.append("\n      综合测评总得分:" + temp[6] + "\n");
					    	this.jingquexianshi.append("\n      综合测评总得分排名:" + temp[7] + "\n");
					    	this.jingquexianshi.append("\n      业务学习排名:" + temp[8] + "\n");
					    	
					    }
					    
					    datain.close();
					    dataout.close();
					    socket.close();
					    socket=null;
					

⌨️ 快捷键说明

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