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

📄 bookeditdialog.java

📁 此文档针对开发人员和测试人员。第二章对软件进行了全面的描述。第三章对接口进行了分析。第四章对软件实现的功能进行概述。第五章对软件后续开发实现提出的要求。第六章提出其他一些在软件开发过程中需要注意的问题
💻 JAVA
字号:
package com.ciash.bms.gui.impl;


import javax.swing.*;
import java.awt.*;
import com.ciash.common.gui.tool.ToolKit;
import javax.swing.UIManager;
import com.ciash.bms.entity.Book;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Vector;
import java.util.Iterator;
import java.util.Collection;

import com.ciash.bms.gui.uiInter.BookEditDialogUI;

/**
 * <p>Title: BMS</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2009</p>
 * <p>Company: Cigarette Ash Inc.</p>
 * @author Cigarette Ash
 * @version 1.0
 */

public class BookEditDialog
extends JDialog implements BookEditDialogUI{

    private BookEditPanel editPanel = new BookEditPanel();
    private JPanel jPanel1 = new JPanel();
    private JButton confirmButton = new JButton();
    private JButton cancelButton = new JButton();
	private Vector listeners = new Vector();

    private int option;

    public BookEditDialog() {
        super(new Frame(), "",true);
        jbInit();
    }

    private void jbInit() {
        confirmButton.setText("jButton1");
        confirmButton.setText("确定");
        cancelButton.setText("取消");
        jPanel1.add(confirmButton, null);
        jPanel1.add(cancelButton, null);
        getContentPane().setLayout(new BorderLayout());
        getContentPane().add(editPanel, BorderLayout.CENTER);
        getContentPane().add(jPanel1, BorderLayout.SOUTH);
        ButtonListener listener = new ButtonListener();
        confirmButton.setActionCommand(ButtonListener.CONFIRM);
        confirmButton.addActionListener(listener);
        cancelButton.setActionCommand(ButtonListener.CANCEL);
        cancelButton.addActionListener(listener);
        addWindowListener(listener);
        setResizable(false);
    }

	public void setVisible(boolean isVisible){
        setSize(450,450);
        setLocation(ToolKit.getScreenCenterLocation(getSize()));
        super.setVisible(isVisible);
    }

    public Book getBook() {
        return editPanel.getSelectBook();
    }

    private void setBook(Book book) {
        editPanel.setSelectBook(book);
    }

    public void clearBook(){
    	editPanel.setSelectBook(null);
    }

    public int showDialog(Book book, Collection genus) {
    	setTitle("编辑图书");
    	editPanel.setSelectBook(book);
    	editPanel.setGenus(genus);
        this.setVisible(true);
        return option;
    }

    public int showDialog(Collection genus) {
    	setTitle("添加图书");
        editPanel.setGenus(genus);
        editPanel.setSelectBook(null);
        this.setVisible(true);
        return option;
    }

    public int showDialog() {
    	setTitle("添加图书");
        try {
            throw new Exception("this method can not be transfer");
        }
        catch (Exception ex) {
        	ex.printStackTrace();
            System.exit(0);
        }
        return -109999;
    }

    public int getOption() {
        return option;
    }

    private class ButtonListener extends WindowAdapter implements ActionListener{

		public final static String CONFIRM = "确定";
        public final static String CANCEL = "取消";

        public void actionPerformed(ActionEvent e) {
            String command = e.getActionCommand();
            if (command.equals(CONFIRM)) {
            	if(editPanel.checkValues()){
            		option = OK_OPTION;
            		setVisible(false);
            	}
			}
            else if(command.equals(CANCEL)){
                option = CANCEL_OPTION;
                setVisible(false);
            }
        }

        public void windowClosing(WindowEvent e) {
        	option = CANCEL_OPTION;
            setVisible(false);
        }
    }
}

⌨️ 快捷键说明

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