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

📄 logindialog.java

📁 简单的JAVA程序,给大家稍微看看 还没有连数据库
💻 JAVA
字号:
package com.studentmanage;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Dialog;
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 LoginDialog extends Dialog
{

	private Combo cmbLoginType;
	private Text txtPassword;
	private Text txtUserName;
	protected Object result;
	private boolean isLogin;
	private Label lbCount;
	protected Shell shell;

	/**
	 * Create the dialog
	 * @param parent
	 * @param style
	 */
	public boolean getIsLogin()
		{
			return isLogin;
		}

	public LoginDialog(Shell parent, int style)
	{
		super(parent, style);
	}

	/**
	 * Create the dialog
	 * @param parent
	 */
	public LoginDialog(Shell parent)
	{
		this(parent, SWT.NONE);
	}

	/**
	 * Open the dialog
	 * @return the result
	 */
	public Object open()
		{
			createContents();
			shell.open();
			shell.layout();
			Display display = getParent().getDisplay();
			while (!shell.isDisposed())
			{
				if (!display.readAndDispatch())
					display.sleep();
			}
			return result;
		}

	/**
	 * Create contents of the dialog
	 */
	protected void createContents()
		{
			shell = new Shell(getParent(), SWT.DIALOG_TRIM
					| SWT.APPLICATION_MODAL);
			shell.setSize(319, 240);
			shell.setText("学生管理系统--登陆界面");

			final Label label = new Label(shell, SWT.NONE);
			label.setText("用户名:");
			label.setBounds(27, 33, 65, 20);

			txtUserName = new Text(shell, SWT.BORDER);
			txtUserName.setBounds(98, 32, 140, 21);

			final Label label_1 = new Label(shell, SWT.NONE);
			label_1.setBounds(31, 78, 54, 20);
			label_1.setText("密 码:");
			
			lbCount = new Label(shell, SWT.NONE);
			lbCount.setBounds(201, 56, 40, 19);

			txtPassword = new Text(shell, SWT.BORDER);
			txtPassword.addModifyListener(new ModifyListener() {
				public void modifyText(ModifyEvent arg0) {
						lbCount.setText(""+txtPassword.getText().length()+"位");
				}
			});
			txtPassword.setBounds(97, 75, 142, 20);
			txtPassword.setEchoChar('*');

			final Button btnCancel = new Button(shell, SWT.NONE);
			btnCancel.addSelectionListener(new SelectionAdapter() {
				public void widgetSelected(SelectionEvent arg0) {
						shell.close();
						
				}
			});
			btnCancel.setText("取消");
			btnCancel.setBounds(47, 150, 61, 28);

			final Button btnOk = new Button(shell, SWT.NONE);
			btnOk.addSelectionListener(new SelectionAdapter() {
				public void widgetSelected(SelectionEvent arg0) {
						//通过 Login类验证并返回验证结果
						Login log=new Login(txtUserName.
								getText(),txtPassword.getText(),cmbLoginType.getText());
						isLogin=log.validate();
						shell.close();
				}
			});
			btnOk.setBounds(176, 150, 61, 28);
			btnOk.setText("确定");

			cmbLoginType = new Combo(shell, SWT.NONE);
			cmbLoginType.setBounds(98, 111, 94, 20);
			cmbLoginType.add("学生");
			cmbLoginType.select(0);
			cmbLoginType.add("老师");
			cmbLoginType.add("管理员");
			
			
			

			final Label label_1_1 = new Label(shell, SWT.NONE);
			label_1_1.setBounds(25, 114, 54, 20);
			label_1_1.setText("登陆类型:");

			

			//
		}

	

}

⌨️ 快捷键说明

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