📄 serverlogin.java
字号:
package dssserver;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class ServerLogin {
private static Text tloginname;
private static Text tloginpswd;
/**
* Launch the application
* @param args
*/
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setSize(307, 293);
shell.setText("数字签名系统服务器登录");
shell.open();
tloginname = new Text(shell, SWT.BORDER);
tloginname.setBounds(105, 83, 129, 25);
tloginpswd = new Text(shell, SWT.BORDER);
tloginpswd.setBounds(105, 133, 129, 25);
final Button buttonlogin = new Button(shell, SWT.NONE);
buttonlogin.setText("确定");
buttonlogin.setBounds(41, 199, 44, 23);
buttonlogin.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
String loginname = tloginname.getText();
String loginpswd = tloginpswd.getText();
DataBase db = new DataBase();
if(loginname.equals(""))
MessageDialog.openWarning(null, "注意", "用户名不能为空");
else if(loginpswd.equals(""))
MessageDialog.openWarning(null, "注意", "密码不能为空");
else if(!loginpswd.equals("")&&!loginname.equals("") ){
if(db.checkuser(loginname, loginpswd)){
MessageDialog.openWarning(null, "登录信息", "登录成功");
display.dispose();
ServerMain sapp = new ServerMain();
sapp.NewSocket();
}
else{
MessageDialog.openWarning(null, "登录信息", "登录失败");
}
}
}
});
final Button buttoncancel = new Button(shell, SWT.NONE);
buttoncancel.setText("取消");
buttoncancel.setBounds(190, 199, 44, 23);
buttoncancel.addSelectionListener(new ButtoncancelSelectionListener());
final Label labelname = new Label(shell, SWT.NONE);
labelname.setText("用户:");
labelname.setBounds(41, 86, 44, 16);
final Label labelpswd = new Label(shell, SWT.NONE);
labelpswd.setText("密码:");
labelpswd.setBounds(41, 136, 44, 13);
final Label labellogin = new Label(shell, SWT.NONE);
labellogin.setText("请填写用户名密码:");
labellogin.setBounds(10, 41, 109, 13);
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
private static final class ButtoncancelSelectionListener extends SelectionAdapter{
public void widgetSelected(SelectionEvent e){
tloginname.setText("");
tloginpswd.setText("");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -