?? printergroupinfopanel.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 + -