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

📄 outputpanel.java

📁 学生信息读系统(根据学生的学号从存储系统读取学生信息): 姓名
💻 JAVA
字号:
//This class show all the requied information of a student
//to user. 
import java.awt.Component;
import java.awt.Label;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Dimension;
import javax.swing.JPanel;
import javax.swing.JTable;
import java.awt.Color;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.TextField;
import java.awt.Dialog;

public class OutputPanel extends JPanel implements ActionListener
{
	Label l1=null;
	Label l2=null;
	Label l3=null;
	Label l4=null;
	JTable table=null;
	InfoTableModel itm=null;
	Button b=null;
	TextField tf1=null;
	TextField tf2=null;
	
	GridBagLayout la=null;
	GridBagConstraints c=null;
	
	protected String stuClass=null;
	protected String stuID=null;
	
	public OutputPanel()
	{
		la=new GridBagLayout();
		c=new GridBagConstraints();
		setLayout(la);
		inital();
		setVisible(true);
	}
	
	public void inital()
	{
		l1=new Label("请输入您要查询学生的班级和学号:");
		l3=new Label("             班级");
		l4=new Label("             学号");
		l2=new Label("     学号:"+"null"+"     姓名:"+"null");
		tf1=new TextField();
		tf2=new TextField();
		b=new Button("查询");
		
		b.addActionListener(this);
		
		c.fill=GridBagConstraints.BOTH;
		c.weightx=1.0;
		c.gridwidth=GridBagConstraints.REMAINDER;
		addCom(l1,la,c);
		c.fill=GridBagConstraints.BOTH;
		c.weightx=1.0;
		c.gridwidth=1;
		addCom(l3,la,c);
		addCom(tf1,la,c);
		addCom(l4,la,c);
		addCom(tf2,la,c);
		c.gridwidth=GridBagConstraints.REMAINDER;
		addCom(b,la,c);
		c.gridwidth=GridBagConstraints.REMAINDER;
		addCom(l2,la,c);
		table=new JTable(9,3);
		table.setEnabled(false);
		addCom(table,la,c);
	}
	
	public void addCom(Component c1,GridBagLayout l,GridBagConstraints c)
	{
		l.setConstraints(c1,c);
		add(c1);
	}
	
	public void actionPerformed(ActionEvent e)
	{
		stuClass=tf1.getText();
		stuID=tf2.getText();
		try
	    {
		    itm=new InfoTableModel(stuClass,stuID);
		    remove(l2);
			remove(table); 
			l2=new Label("     学号:"+itm.stuID+"     姓名:"+itm.stuName);
			table=new JTable(itm);
			c.gridwidth=GridBagConstraints.REMAINDER;
			addCom(l2,la,c);
			c.gridwidth=GridBagConstraints.REMAINDER;
			addCom(table,la,c);
			this.getParent().setVisible(true);
		}
		catch(Exception es)
		{
		}
	}
}

⌨️ 快捷键说明

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