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

📄 placeinfopanel.java

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

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.place.PlaceInfo;
import jp.co.ntl.preference.PreferenceInfo;

public class PlaceInfoPanel extends AbstractDetailInfoPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private JLabel			lblPlaceName;
	private JTextField		txtPlaceName;
	
	private PlaceInfo		placeInfo;
	private Vector			vcPlaceInfo;
	
	public PlaceInfoPanel(boolean modify, PlaceInfo placeInfo, Vector vcPlaceInfo) {
		super(modify, new Object[] { placeInfo, vcPlaceInfo });
	}
	
	protected void setParams(Object[] params) {
		placeInfo = (PlaceInfo)params[0];
		vcPlaceInfo = (Vector)params[1];
	}

	protected void buildComponents() {
		setLayout(new SpringLayout());
		
		Dimension size = new Dimension(250, 24);
		
		lblPlaceName = new JLabel(Resource.getString(Resource.PLACEINFO_PLACE));
		add(lblPlaceName);

		txtPlaceName = new JTextField();
		txtPlaceName.setPreferredSize(size);
		add(txtPlaceName);
		
		SpringUtilities.makeCompactGrid(this, getComponentCount() / 2, 2, 10, 10, 10, 10);
	}

	protected void setValuesFromComponent() {
		placeInfo.setPlace(txtPlaceName.getText());
	}

	protected void setValuesToComponent() {
		preValue = placeInfo.getPlace();
		txtPlaceName.setText(placeInfo.getPlace());
	}

	
	protected boolean checkValues() {
		CheckUtil	chk = new CheckUtil(Resource.getString(Resource.PLACEINFO_PLACE), this);
		String		place = txtPlaceName.getText();
		
		// 愝抲応強偑枹擖椡偺偲偒
		if (chk.isNull(place)) {
			return false;
		}
		
		// 愝抲応強偺挿偝僠僃僢僋
		if (chk.isLengthOver(place, PlaceInfo.MAX_PLACE_LEN)) {
			return false;
		}
		
		// 愝抲応強偵巊梡偱偒側偄暥帤偑擖椡偝傟偰偄傞偲偒
		if (chk.isValidateChar(place)) {
			return false;
		}
		
		// 愝抲応強偑偡偱偵擖椡嵪傒偺偲偒
		if (!modify || (modify && !preValue.equals(place))) {
			for (int i = 0; i < vcPlaceInfo.size(); i++) {
				PlaceInfo	placeInfo = (PlaceInfo)vcPlaceInfo.elementAt(i);
				if (chk.isAlreadyRegitered(place, placeInfo.getPlace())) {
					return false;
				}
			}
		}
		
		return true;
	}

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


}

⌨️ 快捷键说明

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