对学生类(包括学号、姓名、性别、年龄、爱好等)完成GUI的设计,使能对学生对象进行添加、修改、删除、查询操作

import java.awt.*;
import javax.swing.*;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
import java.awt.event.*;
import java.util.Vector;

class Student {
   
    private int no;
    private String name;
    private String sex;
    private int age;
    private String hobby;

    public int getNo() {
   
        return no;
    }

    public void setNo(int no) {
   
        this.no = no;
    }

    public String getName() {
   
        return name;
    }

    public void setName(String name) {
   
        this.name = name;
    }

    public String getSex() {
   
        return sex;
    }

    public void setSex(String sex) {
   
        this.sex = sex;
    }

    public int getAge() {
   
        return age;
    }

    public void setAge(int age) {
   
        this.age = age;
    }

    public String getHobby() {
   
        return hobby;
    }

    public void setHobby(String hobby) {
   
        this.hobby = hobby;
    }

    public Student(int no,String name,String sex,int age,String hobby){
   
        this.no=no;
        this.name=name;
        this.sex=sex;
        this.age=age;
        this.hobby=hobby;
    }
    public  Student(){
   

    }
    public String toString(){
   
        return "学号:"+no+"   姓名"+name+"  性别:"+sex+"  年龄:"+age+"  爱好:"+hobby+"\n";
    }
}

public class Main extends JFrame{
   
    JMenuBar menuBar;
    Container container;
    CardLayout cardLayout;
    JTextArea jTextArea;
    JPanel mainPanel;
    JPanel detailPanel;
    JPanel addPanel;
    JPanel modifyPanel;
    JTextField modifInput;
    JPanel searchPanel;
    JTextArea searchResault;
    JTextField searchInput;
    JPanel removePanel;
    JTextField removeInput;
    JTextField addNoInput;
    JTextField addNameInput;
    JTextField addAgeInput;
    JTextField addsexInput;
    JTextField addhobbyInput;
    JTextField modifyNoInput;
    JTextField modifyNameInput;
    JTextField modifyAgeInput;
    JTextField modifySexInput;
    JTextField modifyHobbyInput;
    Vector<Student> students;
    Main(){
   
        students = new Vector<Student>();
        students.add(new Student(100,"aa","男",18,"读书"));
        students.add(new Student(101,"bb","男",19,"看报"));
        container = getContentPane();
        mainPanel = new JPanel();
        cardLayout = new CardLayout();//设置卡片布局
        mainPanel.setLayout(cardLayout);
        container.setLayout(new FlowLayout());
        setMenu();//设置菜单
        setDetailPanel();//设置详情页
        setaddPanel();//设置添加对象页
        setRemovePanel();//设置删除对象页
        setModifyPanel();//设置修改对象页
        setSearchPanel();//设置查询对象页
        container.add(mainPanel);
    }
    public void setMenu(){
   
        JMenu menu;
        menuBar = new JMenuBar();
        this.setJMenuBar(menuBar);
        menu = new JMenu("编辑");
        menuBar.add(menu);
        JMenuItem mainItem = new JMenuItem("显示详情");
        mainItem.addActionListener(new ActionListener() {
   
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
   
                cardLayout.show(mainPanel,"detailPanel");//切换卡片页面
                showDetails();
            }
        });
        menu.add(mainItem);
        JMenuItem addItem = new JMenuItem
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值