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

📄 studentin.java

📁 java课后题的详细答案
💻 JAVA
字号:


import java.awt.*;
import java.awt.event.*;
import java.sql.*;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class studentin {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		jframe frame = new jframe();

	}

}
class frameSearch extends JFrame{

	Button buttonSearch ,buttonCancel;
	TextField tfid1, tfid2;
	frameSearch(){
		super("学生信息查询");
		setLayout(null);
		setLocation(100, 200);
		setVisible(true);
		setSize(400,400);
		getContentPane().setBackground(Color.magenta);
		Label ib1 = new Label("姓名 :");
		Label ib2 = new Label("学号 :");
		buttonSearch = new Button("查询");
		buttonCancel = new Button("退出");
		tfid1 = new TextField();
		tfid2 = new TextField();
		ib1.setBounds(30, 170, 40, 20);
		ib2.setBounds(30, 210, 40, 20);
		tfid1.setBounds(80, 170, 200, 20);
		tfid2.setBounds(80, 210, 200, 20);
		buttonSearch.setBounds(80, 50, 80, 30);
		buttonCancel.setBounds(180, 50, 80,30);
		add(ib1);
		add(ib2);
		add(tfid1);
		add(tfid2);
		add(buttonSearch);
		add(buttonCancel);
	}
}
class frameJoin extends JFrame{

	Button buttonJoin , buttonCancel ;
	TextField tfid1, tfid2;
	frameJoin(){
		super("学生信息添加");
		setLayout(null);
		setLocation(100, 200);
		setSize(400,400);
		setVisible(true);
		getContentPane().setBackground(Color.magenta);
		Label ib1 = new Label("姓名 :");
		Label ib2 = new Label("学号 :");
		buttonJoin = new Button("添加");
		buttonCancel = new Button("退出");
		tfid1 = new TextField();
		tfid2 = new TextField();
		ib1.setBounds(30, 170, 40, 20);
		ib2.setBounds(30, 210, 40, 20);
		tfid1.setBounds(80, 170, 200, 20);
		tfid2.setBounds(80, 210, 200, 20);
		buttonJoin.setBounds(80, 50, 80, 30);
		buttonCancel.setBounds(180, 50, 80,30);
		add(ib1);
		add(ib2);
		add(tfid1);
		add(tfid2);
		add(buttonJoin);
		add(buttonCancel);
	}
}
class frameDelete extends JFrame{

	Button buttonDelete,buttonCancel ;
	TextField tfid1, tfid2;
	frameDelete(){
		super("学生信息删除");
		setLayout(null);
		setLocation(100, 200);
		setVisible(true);
		setSize(400,400);
		getContentPane().setBackground(Color.magenta);
		Label ib1 = new Label("姓名 :");
		Label ib2 = new Label("学号 :");
		buttonDelete = new Button("删除");
		buttonCancel = new Button("退出");
		tfid1 = new TextField();
		tfid2 = new TextField();
		ib1.setBounds(30, 170, 40, 20);
		ib2.setBounds(30, 210, 40, 20);
		tfid1.setBounds(80, 170, 200, 20);
		tfid2.setBounds(80, 210, 200, 20);
		buttonDelete.setBounds(80, 50, 80, 30);
		buttonCancel.setBounds(180, 50, 80,30);
		add(ib1);
		add(ib2);
		add(tfid1);
		add(tfid2);
		add(buttonDelete);
		add(buttonCancel);
	}
}
class frameChange extends JFrame{

	Button buttonChange ,buttonCancel;
	TextField tfid1, tfid2;
	frameChange(){
		super("学生信息修改");
		setLayout(null);
		setLocation(100, 200);
		setVisible(true);
		setSize(400,400);
		getContentPane().setBackground(Color.magenta);
		Label ib1 = new Label("姓名 :");
		Label ib2 = new Label("学号 :");
		buttonChange = new Button("修改");
		buttonCancel = new Button("退出");
		tfid1 = new TextField();
		tfid2 = new TextField();
		ib1.setBounds(30, 170, 40, 20);
		ib2.setBounds(30, 210, 40, 20);
		tfid1.setBounds(80, 170, 200, 20);
		tfid2.setBounds(80, 210, 200, 20);
		buttonChange.setBounds(80, 50, 80, 30);
		buttonCancel.setBounds(180, 50, 80,30);
		add(ib1);
		add(ib2);
		add(tfid1);
		add(tfid2);
		add(buttonChange);
		add(buttonCancel);
	}
}
class jframe extends JFrame implements ActionListener{
	MenuBar menubar1;
	Menu Menu1,Menu2,Menu3,Menu4,Menu5;
	MenuItem item1,item2,item3,item4,item5;
	jframe(){
		super("学生信息管理系统");
		setLayout(null);
		setLocation(20, 50);
		setSize(600,600);
		setVisible(true);
		getContentPane().setBackground(Color.magenta);
		setBackground(Color.blue);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		menubar1 = new MenuBar();

		Menu1 = new Menu("查询");
		Menu2 = new Menu("添加");
		Menu3 = new Menu("修改");
		Menu4 = new Menu("删除");
		Menu5 = new Menu("退出");
		
		item1 = new MenuItem("查询");
		item2 = new MenuItem("添加");
		item3 = new MenuItem("修改");
		item4 = new MenuItem("删除");
		item5 = new MenuItem("退出");
		
		Menu1.add(item1);
		Menu2.add(item2);
		Menu3.add(item3);
		Menu4.add(item4);
		Menu5.add(item5);
		menubar1.add(Menu1);
		menubar1.add(Menu2);
		menubar1.add(Menu3);
		menubar1.add(Menu4);
		menubar1.add(Menu5);
		setMenuBar(menubar1);

		item1.addActionListener(this);
		item2.addActionListener(this);
		item3.addActionListener(this);
		item4.addActionListener(this);
		item5.addActionListener(this);
	}
	public void actionPerformed(ActionEvent e){
		
		// TODO Auto-generated method stub
		if(e.getSource() == item1){
			try{
				frameSearch frame = new frameSearch();
				
			}catch(Exception e1){
				System.out.println(e1.toString());
			}
		}
		
		if(e.getSource() == item2){
			try{
				frameJoin frame = new frameJoin();
			}catch(Exception e1){
				System.out.println(e1.toString());
			}
		}
		if(e.getSource() == item3){
			try{
				frameChange frame = new frameChange();
			}catch(Exception e1){
				System.out.println(e1.toString());
			}
		}
		if(e.getSource() == item4){
			try{
				frameDelete frame = new frameDelete();
			}catch(Exception e1){
				System.out.println(e1.toString());
			}
		}
		if(e.getSource() == item5){
			try{
				
			}catch(Exception e1){
				System.out.println(e1.toString());
			}
			System.exit(0);
		}

	}
	
}

⌨️ 快捷键说明

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