二、Eclipse3.0的swt编程 1.swt比awt和swing要快多,因为它是利用操作系统的界面组件生成UI的,在java桌面设计领域掀起一场革命 2.环境配置: windows系统+eclipse3.0 3.具体操作: (1).新建一java项目,命名swt,文件结构如下:
+swt +bin(编译输出) +src(原文件) +AddressBookUI.java +swt-awt-win32-3062.dll(以下均从eclipse\plugins\org.eclipse.swt.win32_3.0.1\os\win32\x86下导入) +swt-win32-3062.dll +javaw.exe.manifest (2).到项目的properties里,在java build path | libraries里将swt.jar导入
(3).AddressBookUI.java原代码如下:
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.*; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; public class AddressBookUI { private Shell shell; private Text miscText; private Text addrText; private Text emailText; private Text phoneText; private Text lnameText; private Text fnameText; private Button cancelButton; private Button saveButton; private Button nextButton; private Button prevButton; private Button editButton; private Button deleteButton; private Button newButton;
|