标签:java
package com.net.ui; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.widgets.Group; import com.net.utils.SWTUtil; import com.swtdesigner.SWTResourceManager; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; public class Login_NoPassWord { protected Shell shell; private Text text; /** * Launch the application. * @param args */ public static void main(String[] args) { try { Login_NoPassWord window = new Login_NoPassWord(); window.open(); } catch (Exception e) { e.printStackTrace(); } } /** * Open the window. */ public void open() { Display display = Display.getDefault(); createContents(); SWTUtil.centerShell(display, shell); shell.open(); shell.layout(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } /** * Create contents of the window. */ protected void createContents() { shell = new Shell(SWT.NONE); shell.setBackgroundMode(SWT.INHERIT_DEFAULT); shell.setBackgroundImage(SWTResourceManager.getImage(Login_NoPassWord.class, "/images/Login_background.png")); shell.setSize(450, 300); shell.setText("登陆界面"); Composite composite = new Composite(shell, SWT.NONE); composite.setBounds(189, 86, 160, 28); text = new Text(composite, SWT.BORDER); text.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 12, SWT.NORMAL)); text.setBounds(0, 0, 160, 27); Label label = new Label(shell, SWT.NONE); label.setBounds(113, 86, 46, 28); label.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 14, SWT.BOLD)); label.setText("账号"); Button button = new Button(shell, SWT.NONE); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Login_NoPassWord.this.shell.dispose(); Main main = new Main(); main.open(); } }); button.setBounds(164, 175, 80, 25); button.setText("登陆"); } }
标签:java
原文地址:http://zhaotianff.blog.51cto.com/3361664/1657325