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

📄 dialogmanager.java

📁 打印管理程序,测试完全通过.windows开发环境.
💻 JAVA
字号:
package jp.co.ntl.swing.ext;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JOptionPane;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;

import jp.co.ntl.swing.CustomDialog;
import jp.co.ntl.swing.ValidatePanel;
import jp.co.ntl.Util;

public class DialogManager implements ActionListener, MessageConstants {
	private static CustomDialog		customDialog = null;
	private static MessageDialog		msgDialog = null;
	private static JFileChooser		fileDialog = null;
	private MainBasePanel				mainPanel;
	
	public DialogManager(MainBasePanel mainPanel) {
		this.mainPanel = mainPanel;
		mainPanel.addActionListener(this);
	}
	
	public static CustomDialog getCustomDialogObject() {
		return customDialog;
	}
	
	public static MessageDialog getMessageDialogObject() {
		return msgDialog;
	}
	
	public static JFileChooser getFileDialogObject() {
		return fileDialog;
	}

	public boolean isShowingDialog() {
		boolean	b = false;
		if (customDialog != null) {
			b = customDialog.isShowing();
		}
		
		if (!b) {
			if (msgDialog != null) {
				b = msgDialog.isShowing();
			}
		}
		
		if (!b) {
			if (fileDialog != null) {
				b = fileDialog.isShowing();
			}
		}
		
		return b;
	}
	
	public void actionPerformed(ActionEvent ae) {
		Object	obj = ae.getSource();
		if (obj == mainPanel) {
			if (customDialog != null && customDialog.isShowing()) {
				customDialog.setVisible(false);
				customDialog = null;
			}
			
			if (msgDialog != null && msgDialog.isShowing()) {
				msgDialog.hideDialog();
				msgDialog = null;
			}
			
			if (fileDialog != null && fileDialog.isShowing()) {
				fileDialog.cancelSelection();
				fileDialog = null;
			}
		}
	}
	
    public static int showCustomDialog(Component parent, String title, ValidatePanel vpanel) {
    	customDialog = new CustomDialog(CustomDialog.getFrameForComponent(parent), title, true, vpanel);
        customDialog.setVisible(true);
        
        int	ret = CustomDialog.UNINITIALIZED_VALUE;
        if (customDialog != null) {
        	ret = customDialog.getSelection();
            customDialog = null;
        }
        return ret;
    }
    
	public static void showMessage(Component parent, int msgID) {
		showMessage(parent, msgID, null);
	}
	
	public static void showMessage(Component parent, int msgID, String[] param) {
		int	type = MessageDialog.WARNING_MESSAGE;
		if (msgID >= MessageDialog.DOWNLOAD_SUCCESS) {
			type = JOptionPane.INFORMATION_MESSAGE;
		}
		
		msgDialog = new MessageDialog(MsgUtil.getMessage(msgID, param), type);
		msgDialog.showDialog(parent);
		msgDialog = null;
	}
	
	public static int showConfirmMessage(Component parent, int msgID, int optionType) {
		return showConfirmMessage(parent, msgID, optionType, null);
	}
	
	public static int showConfirmMessage(Component parent, int msgID, int optionType, String[] param) {
		int	type = MessageDialog.WARNING_MESSAGE;
		if (msgID >= MessageDialog.DOWNLOAD_SUCCESS) {
			type = MessageDialog.INFORMATION_MESSAGE;
		}
		
		msgDialog = new MessageDialog(MsgUtil.getMessage(msgID, param), type, optionType);
		msgDialog.showDialog(parent);
		int	ret = MessageDialog.CLOSED_OPTION;
		if (msgDialog != null) {
			ret = msgDialog.getSelection();
			msgDialog = null;
		}
		return ret;
	}
	
	public static int showOpenDialog(Component parent, FileFilter filter) {
		fileDialog = new JFileChooser();
		fileDialog.setFileFilter(filter);
		return fileDialog.showOpenDialog(parent);
	}
	
	public static int showSaveDialog(Component parent, FileFilter filter) {
		fileDialog = new JFileChooser();
		fileDialog.setFileFilter(filter);
		return fileDialog.showSaveDialog(parent);
	}
	
	public static int doOpenServerInfoDlg(Component parent) {
		Resource.load(Util.getCurrentLocale());
		ServerSettingPanel	serverSettingPanel = new ServerSettingPanel();
		return showCustomDialog(parent, Resource.getString(Resource.TITLE_SERVER_SETTING), serverSettingPanel);
	}
}

⌨️ 快捷键说明

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