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

📄 printergroupinfopanel.java

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

import java.awt.Dimension;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SpringLayout;

import jp.co.ntl.swing.SpringUtilities;
import jp.co.ntl.swing.ext.AbstractDetailInfoPanel;
import jp.co.ntl.ext.CheckUtil;
import jp.co.ntl.printergroup.PrinterGroupInfo;
import jp.co.ntl.preference.PreferenceInfo;

public class PrinterGroupInfoPanel extends AbstractDetailInfoPanel {
	/**
	 * 
	 */
	private static final long	serialVersionUID	= 1L;

	private JLabel				lblPrinterGroup;
	private JTextField			txtPrinterGroup;
	
	private PrinterGroupInfo	printerGroupInfo;
	private Vector				vcPrinterGroupInfo;
	
	public PrinterGroupInfoPanel(boolean modify, PrinterGroupInfo printerGroupInfo, Vector vcPrinterGroupInfo) {
		super(modify, new Object[] { printerGroupInfo, vcPrinterGroupInfo });
	}
	
	protected void setParams(Object[] params) {
		this.printerGroupInfo = (PrinterGroupInfo)params[0];
		this.vcPrinterGroupInfo = (Vector)params[1];
	}
	
	protected void buildComponents() {
		setLayout(new SpringLayout());
		
		Dimension	size = new Dimension(250, 24);
		
		lblPrinterGroup = new JLabel(Resource.getString(Resource.PRINTERGROUPINFO_PRINTERGROUP));
		add(lblPrinterGroup);
		
		txtPrinterGroup = new JTextField();
		txtPrinterGroup.setPreferredSize(size);
		add(txtPrinterGroup);
		
		SpringUtilities.makeCompactGrid(this, getComponentCount() / 2, 2, 10, 10, 10, 10);
	}
	
	protected void setValuesToComponent() {
		preValue = printerGroupInfo.getPrinterGName();
		txtPrinterGroup.setText(printerGroupInfo.getPrinterGName());
	}
	
	protected void setValuesFromComponent() {
		printerGroupInfo.setPrinterGName(txtPrinterGroup.getText());
	}
	
	protected boolean checkValues() {
		CheckUtil	chk = new CheckUtil(Resource.getString(Resource.PRINTERGROUPINFO_PRINTERGROUP), this);
		String	printerG = txtPrinterGroup.getText();
		
		// 僾儕儞僞僌儖乕僾柤偑枹擖椡偺偲偒
		if (chk.isNull(printerG)) {
			return false;
		}
			
		// 僾儕儞僞僌儖乕僾柤偺挿偝僠僃僢僋
		if (chk.isLengthOver(printerG, PrinterGroupInfo.MAX_PRINTER_GROUP_NAME_LEN)) {
			return false;
		}
		
		// 僾儕儞僞僌儖乕僾柤偵巊梡偱偒側偄暥帤偑擖椡偝傟偰偄傞偲偒
		if (chk.isValidateChar(printerG)) {
			return false;
		}
			
		// 僾儕儞僞僌儖乕僾柤偑偡偱偵擖椡偝傟偰偄傞偲偒
		if (!modify || modify && !preValue.equals(printerG)) {
			for (int i = 0; i < vcPrinterGroupInfo.size(); i++) {
				PrinterGroupInfo	pg = (PrinterGroupInfo)vcPrinterGroupInfo.elementAt(i);
				if (chk.isAlreadyRegitered(printerG, pg.getPrinterGName())) {
					return false;
				}
			}
		}

		return true;
	}

	public JButton[] getButtons() {
		if (clientKind == PreferenceInfo.CLIENT_MAC) {
			return new JButton[] {
					new JButton(Resource.getString(Resource.PRINTERGROUPINFO_CANCEL)),
					new JButton(Resource.getString(Resource.PRINTERGROUPINFO_OK))
					
			};
		} else {
			return new JButton[] {
					new JButton(Resource.getString(Resource.PRINTERGROUPINFO_OK)),
					new JButton(Resource.getString(Resource.PRINTERGROUPINFO_CANCEL))
			};
		}
	}
}

⌨️ 快捷键说明

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