operateframe.java

来自「利用JAVA开发的简单考试系统」· Java 代码 · 共 73 行

JAVA
73
字号
package viewer;

import javax.swing.JPanel;
import java.awt.Rectangle;
import javax.swing.JButton;
import model.persistency.PersistentItem;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JOptionPane;
import java.awt.Point;
import java.awt.Dimension;
/**
 * <p>Title: </p>
 * 管理操作框架
 * <p>Description: </p>
 * 此框架是整个管理操作的父框架,同时又是UserFrame的子框架。
 * 该框架有一个submit按钮,用于提交操作结果
 * 对父类的end命令重新定义操作
 */
public class OperateFrame extends UserFrame{
    PersistentItem t;

    JButton subButton = new JButton();
    /**
     * constructor
     */
    public OperateFrame() {
        super();
        try {
            jbInit();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
       // this.setJMenuBar(jMenuBar1);
         setSize(new Dimension(525, 440));
        setTitle("OLTS System");

        subButton.setActionCommand("subButton");
        subButton.setBounds(new Rectangle(230, 353, 81, 26));
        subButton.setText("Submit");
        super.endButton.addActionListener(new endButton_actionAdapter(this));
        super.endMenuItem.addActionListener(new endButton_actionAdapter(this));
        this.getContentPane().add(subButton);
    }
    /**
     * 对父类的end菜单项和end按钮进行重新定义监听事件
     * 销毁当前操作框架,生成UserFrame框架
     * @param e ActionEvent
     */
    public void endButton_actionPerformed(ActionEvent e) {
        this.dispose();
        UserFrame frame = new UserFrame();
        frame.setVisible(true);}

}


class endButton_actionAdapter implements ActionListener {
    private OperateFrame adaptee;
    endButton_actionAdapter(OperateFrame adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.endButton_actionPerformed(e);
    }
}


⌨️ 快捷键说明

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