📄 checkloginuserpanelbase.java
字号:
package jp.co.ntl.swing.ext;
import java.awt.Point;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import javax.swing.JApplet;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import jp.co.ntl.Net;
import jp.co.ntl.NetworkException;
import jp.co.ntl.ServerException;
import jp.co.ntl.TimeOutException;
import jp.co.ntl.swing.BasePanel;
import jp.co.ntl.swing.ext.spstool.Resource;
public class CheckLoginUserPanelBase extends BasePanel implements ComponentListener {
/**
*
*/
private static final long serialVersionUID = 1L;
protected JLabel lblMsg;
protected JLabel lblUserID, lblPassword;
protected JTextField txtUserID;
protected JPasswordField txtPassword;
protected Dimension dim;
public CheckLoginUserPanelBase(JFrame parent, Net net) {
this(parent, net, BasePanel.ADMIN_PANEL);
}
public CheckLoginUserPanelBase(JApplet app, Net net) {
this(app, net, BasePanel.ADMIN_PANEL);
}
public CheckLoginUserPanelBase(JFrame parent, Net net, int kind) {
super(parent, net, kind);
}
public CheckLoginUserPanelBase(JApplet app, Net net, int kind) {
super(app, net, kind);
}
protected void buildComponents() {
setLayout(null);
//dim = app.getSize();
dim = new Dimension(1024, 768);
Point pt = calcControlLocation();
lblMsg = new JLabel("", JLabel.CENTER);
lblMsg.setFont(new Font(null, Font.BOLD, 24));
lblMsg.setBounds(0, pt.y + 50, dim.width, 100);
add(lblMsg);
// 儘僌僀儞柤丄僷僗儚乕僪擖椡棑傪昞帵
lblUserID = new JLabel(Resource.getString(Resource.USER_ID));
txtUserID = new JTextField();
txtUserID.enableInputMethods(true);
lblPassword = new JLabel(Resource.getString(Resource.PASSWORD));
txtPassword = new JPasswordField();
addComponentListener(this);
}
protected Point calcControlLocation() {
Point pt = new Point();
if (kind != ADMIN_PANEL) {
pt.x = (dim.width - 200) / 2;
pt.y = (dim.height - dim.height / 6 * 5) / 2;
} else {
pt.x = (dim.width - 200) / 2;
pt.y = (dim.height - dim.height / 4 * 3) / 2;
}
return pt;
}
public void beginPanel() throws NetworkException, ServerException, TimeOutException {
txtUserID.setText("");
txtPassword.setText("");
txtPassword.setCaretPosition(0);
}
public void setKeyboardFocus() {
txtUserID.requestFocus();
}
protected boolean doDelete() throws NetworkException, ServerException, TimeOutException {
return true;
}
protected boolean doModify() throws NetworkException, ServerException, TimeOutException {
return true;
}
protected boolean doRegister() throws NetworkException, ServerException, TimeOutException {
return true;
}
public int getInfosFromServer() {
return GET_INFO_RESULT_NORMAL;
}
protected void setPopupMenuState() {
}
public void setMessage(String message) {
lblMsg.setText(message);
lblMsg.repaint();
}
public String getUserName() {
return txtUserID.getText();
}
public char[] getPassword() {
return txtPassword.getPassword();
}
public void setState(boolean state) {
lblUserID.setEnabled(state);
txtUserID.setEnabled(state);
lblPassword.setEnabled(state);
txtPassword.setEnabled(state);
}
public void recalcControlBounds() {
dim = app.getSize();
Point pt = calcControlLocation();
lblMsg.setBounds(0, pt.y + 50, dim.width, 100);
}
public void componentHidden(ComponentEvent ce) {
}
public void componentMoved(ComponentEvent ce) {
}
public void componentResized(ComponentEvent ce) {
//recalcControlBounds();
}
public void componentShown(ComponentEvent ce) {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -