没有合适的资源?快使用搜索试试~ 我知道了~
SWT 教程(Java图形界面开发)
4星 · 超过85%的资源 需积分: 49 467 下载量 41 浏览量
2011-12-02
22:55:38
上传
评论 2
收藏 1.49MB PDF 举报
温馨提示
试读
88页
Java语言的声望和它在桌面应用程序(GUI程序)所取得的成就显然极不相符,至今仍然很少能看到非 常成功Java桌面程序。虽然有JBuilder,Netbean,JProbe等大型软件作为代表,但这仍不能证明Java的 GUI程序是成功的:它们的外观总是和同一操作系统平台下的其它软件显得格格不入。对机器配置的需 求也似乎永无止境,这使得它们只能被一些总是拥有当前最高性能PC的程序员们所容忍,或是那些不 在乎金钱和时间的专业用户所接受。对绝大多数计算机使用者来说,AWT或SWING代表着怪异的界面 和无法接受的速度。Standard Widget Toolkit(SWT)或许是Java这一噩梦的终结者,广大Java程序员终 于可以开发出高效率的GUI程序,它们拥有标准的外观,几乎没有人能看出你的程序是用Java写出来 的,更为重要的是,这些程序是跨平台的。
资源推荐
资源详情
资源评论
Department of Computer Science 12 - An Eclipse GUI Builder
University of Manitoba
i
www.cs.umanitoba.ca/~eclipse
12 - An Eclipse GUI Builder
Overview: .................................................................................................................... 1
A GUI Builder:............................................................................................................ 1
Acquiring the Designer Plug-in:.................................................................................. 2
Installation:.................................................................................................................. 2
Activating the Designer:.............................................................................................. 3
Creating a new SWT/JFace Java Project:.................................................................... 3
Creating a new SWT Java File:................................................................................... 4
Parts of the Designer: .................................................................................................. 7
Open Definition and Convert Local to Field Buttons ............................................... 11
Handling Events with the Designer:.......................................................................... 11
Adding an Event Listener with the SWT Designer:.................................................. 12
Deleting an Event Listener with the SWT Designer: ................................................ 14
Using Layout Managers in the SWT Designer: ........................................................ 14
NullLayout: ............................................................................................................... 15
FillLayout: ................................................................................................................. 18
RowLayout: ............................................................................................................... 19
GridLayout: ............................................................................................................... 20
FormLayout (Professional Version Only):................................................................ 22
StackLayout (Professional Version Only):................................................................ 30
BorderLayout (Professional Version Only): ............................................................. 31
FlowLayout (Professional Version Only): ................................................................ 33
GridLayout (AWT) (Professional Version Only): .................................................... 34
Creating Menus in the SWT Designer (Professional Version Only): ....................... 34
Custom Widget Templates (Professional Version Only):......................................... 37
Widget Morphing (Professional Version Only): ....................................................... 38
Custom Composites (Professional Version Only): ................................................... 38
JFace Viewers (Professional Version Only): ............................................................ 41
Custom JFace Dialog Creation:................................................................................. 42
JFace Wizard Page Creation (Professional Version Only): ...................................... 44
JFace Application Creation (Professional Version Only): ........................................ 46
Code Generation Options: ......................................................................................... 50
Type Specific Code Generation Options (Professional Version Only):.................... 52
Additional Features of the Designer:......................................................................... 53
Creating a UI: Two Examples ................................................................................... 55
Creating a GUI for an Address Book Application: ................................................... 55
Creating a new Project: ............................................................................................. 55
Creating a new SWT Application: ............................................................................ 55
Designing the GUI Window:..................................................................................... 56
Creating Menus: ........................................................................................................ 61
Creating Event Handlers: .......................................................................................... 63
Creating an SWT GUI for a Client Billing Application:........................................... 65
Taking a Look at the Original GUI: .......................................................................... 66
Creating Our Own ClientBillingUI: .......................................................................... 67
Creating the Client List Group: ................................................................................. 68
Department of Computer Science 12 - An Eclipse GUI Builder
University of Manitoba
ii
www.cs.umanitoba.ca/~eclipse
Creating a Tabbed Folder:......................................................................................... 69
The Clients Tab: ........................................................................................................ 69
The Transactions Tab: ............................................................................................... 71
Creating a Menu: ....................................................................................................... 72
Running the Application: .......................................................................................... 73
Creating a Swing GUI for the Client Billing Application:........................................ 73
Creating the ClientBillingUI: .................................................................................... 73
Creating the Client List JPanel:................................................................................. 75
Creating a JTabbedPane: ........................................................................................... 78
The Clients Tab: ........................................................................................................ 79
The Transactions Tab: ............................................................................................... 81
Creating a Menu: ....................................................................................................... 85
Running the Application: .......................................................................................... 86
Summary: .................................................................................................................. 86
Department of Computer Science 12 - An Eclipse GUI Builder
University of Manitoba 1 www.cs.umanitoba.ca/~eclipse
12 - An Eclipse GUI Builder
1, 2
by Raphael Enns and Shantha Ramachandran
Department of Computer Science, University of Manitoba, Winnipeg, Manitoba, Canada
Last revised: May 21, 2004
Overview:
In this tutorial, we describe how to use a GUI Builder plug-in for Eclipse, as well as look
at its features. The GUI Builder that we will look at in this tutorial is the Designer
created by Instantiations, Inc., and is available at http://www.swt-designer.com. We will
be using version 2.0.0 of the Designer in this tutorial.
A GUI Builder:
In the previous tutorials, we have seen that SWT and Eclipse are fairly simple and
straightforward to use. One of the most common questions about SWT, however, is
“Where is the GUI Builder?” The answer is that there is no GUI Builder that comes with
Eclipse. However, because Eclipse is open source and designed for plug-ins, a GUI
Builder plug-in is able to be made and can be integrated right into Eclipse.
The Designer is a plug-in that allows you design SWT and Swing GUIs in Eclipse. The
Designer is available at http://www.swt-designer.com. A restricted version of the plug-in
is available for free download at the above website. There is also a professional version,
which includes extra features, that is available for $199 USD. Look at
http://www.instantiations.com/swt-designer/comparison.html to see a comparison
between the free and the professional versions.
As of version 2.0 of the Designer, Instantiations includes both SWT and Swing support in
the Designer. The SWT part is the same as in previous versions and is called the SWT
Designer. The Swing part is called the Swing Designer and is similar to the SWT
Designer. There is also a WindowBuilder product in the Designer which is simply both
the SWT Designer and the Swing Designer.
Since most of the features are the same or similar between the SWT Designer and the
Swing Designer, this tutorial will mainly look at features of the SWT Designer. To
demonstrate the similarities and the differences between the SWT Designer and the
Swing Designer, one of the examples at the end of this tutorial will be done in Swing.
1
This work was funded by an IBM Eclipse Innovation Grant.
2
© Raphael Enns, Shantha Ramachandran and David Scuse
Department of Computer Science 12 - An Eclipse GUI Builder
University of Manitoba 2 www.cs.umanitoba.ca/~eclipse
Acquiring the Designer Plug-in:
You can download the Designer from the website, http://www.swt-designer.com. It can
be found in the Download section. Make sure you get the correct file for your version of
Eclipse. In order to download the Designer, you must have a username and password.
You can get a username and password by registering at the Designer’s website.
Installation:
Once you have downloaded the Designer, installing it is quite simple. First make sure
Eclipse is closed. Move the zip file into your Eclipse directory and then unzip the file. It
will add three folders to your plugin directory that start with com.swtdesigner.
To make sure that the plug-in was successfully installed, start Eclipse. Go to the menu
item Help > About Eclipse Platform. Click on the Plug-in Details button, and a list will
appear. The Designer and the SWT-Designer Help Plug-in items should appear in the
plug-in list.
In the case that you would wish to remove the Designer from your computer, the
Designer creates a batch file called designer-delete.bat in your Eclipse program
directory. Run this file to remove the Designer.
Department of Computer Science 12 - An Eclipse GUI Builder
University of Manitoba 3 www.cs.umanitoba.ca/~eclipse
Activating the Designer:
Before you begin using the Designer you have to activate it. To start the activation
process, select Window > Preferences inside Eclipse. Select the “+” beside “Designer”
on the left side of the Preferences window, click on License, and then click on the button
that says “Registration and Activation”.
Both SWT and Swing support comes with the Designer product, but depending on your
serial number, only one of the three products is activated. For example, if you have a
valid serial number for the SWT Designer, you can use the SWT functionality of the
Designer, but you will not be able to use the Swing functionality except in evaluation or
free mode. If you have a serial number for WindowBuilder, you will have full use of
both the SWT and Swing functionality of the Designer.
Select the type of Designer that you want to activate, select the desired mode, and then
click Next. Follow the directions in the following pages to activate the Designer. Once it
has been activated you are ready to start designing GUIs.
Creating a new SWT/JFace Java Project:
An SWT/JFace Java Project and a regular Java Project are nearly equivalent. They both
create a Java project and you can use the Designer with both types. The only difference
between an SWT/JFace Java project and a regular Java project is that the SWT/JFace
Java project will automatically add the SWT and JFace jar files to the build path.
剩余87页未读,继续阅读
wdhaotian
- 粉丝: 2
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页