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

📄 personview.java

📁 eclipse开发入门与项目实践
💻 JAVA
字号:
package jenny.plugins.connsql;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.Statement;import org.eclipse.jface.action.IAction;import org.eclipse.jface.viewers.ISelection;import org.eclipse.swt.SWT;import org.eclipse.swt.widgets.Display;import org.eclipse.swt.widgets.Label;import org.eclipse.swt.widgets.Shell;import org.eclipse.swt.widgets.Text;import org.eclipse.ui.IWorkbenchWindow;import org.eclipse.ui.IWorkbenchWindowActionDelegate;/** * Our sample action implements workbench action delegate. * The action proxy will be created by the workbench and * shown in the UI. When the user tries to use the action, * this delegate will be created and execution will be  * delegated to it. * @see IWorkbenchWindowActionDelegate */public class PersonView implements IWorkbenchWindowActionDelegate {	private IWorkbenchWindow window;	/**	 * The constructor.	 */	public PersonView() {	}	/**	 * The action has been activated. The argument of the	 * method represents the 'real' action sitting	 * in the workbench UI.	 * @see IWorkbenchWindowActionDelegate#run	 */	public void run(IAction action) {		try{			/*			 * 连接MySQL数据库			 */			Class.forName("org.gjt.mm.mysql.Driver");			Connection conn=DriverManager.getConnection("jdbc:mysql://localhost/test","root","zgy01");		    			Statement stmt=conn.createStatement();			String sql = "select * from account ";		    ResultSet rs=stmt.executeQuery( sql );		    if( rs.next() ){ 		    			    final Display display = Display.getDefault();			final Shell shell = new Shell();			shell.setSize(300, 200);			shell.setText("SWT Application");			shell.open();			final Label label = new Label(shell, SWT.NONE);			label.setText("个人信息显示");			label.setBounds(0, 0, 198, 28);			Text name = new Text(shell, SWT.BORDER);			name.setBounds(127, 29, 145, 30);			name.setText(rs.getString("username"));			final Label label_1 = new Label(shell, SWT.NONE);			label_1.setText("用户名");			label_1.setBounds(48, 31, 70, 29);			final Label label_1_1 = new Label(shell, SWT.NONE);			label_1_1.setBounds(49, 89, 60, 15);			label_1_1.setText("密码");			Text age = new Text(shell, SWT.BORDER);			age.setBounds(127, 83, 63, 30);			age.setText(rs.getString("password"));						shell.layout();			while (!shell.isDisposed()) {				if (!display.readAndDispatch())					display.sleep();			}		}		}catch(Exception ee){		    ee.printStackTrace();		}			}	/**	 * Selection in the workbench has been changed. We 	 * can change the state of the 'real' action here	 * if we want, but this can only happen after 	 * the delegate has been created.	 * @see IWorkbenchWindowActionDelegate#selectionChanged	 */	public void selectionChanged(IAction action, ISelection selection) {	}	/**	 * We can use this method to dispose of any system	 * resources we previously allocated.	 * @see IWorkbenchWindowActionDelegate#dispose	 */	public void dispose() {	}	/**	 * We will cache window object in order to	 * be able to provide parent shell for the message dialog.	 * @see IWorkbenchWindowActionDelegate#init	 */	public void init(IWorkbenchWindow window) {		this.window = window;	}}

⌨️ 快捷键说明

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