用Eclipse进行可视化JAVA界面设计
- 格式:doc
- 大小:439.50 KB
- 文档页数:13
iAbout the T utorialEclipse is an integrated development environment (IDE) for Java and other programming languages like C, C++, PHP, and Ruby etc. Development environment provided by Eclipse includes the Eclipse Java development tools (JDT) for Java, Eclipse CDT for C/C++, and Eclipse PDT for PHP, among others.This tutorial will teach you how to use Eclipse in your day-2-day life while developing any software project using Eclipse IDE. We will give special emphasis on Java project. AudienceThis tutorial has been prepared for beginners to help them understand basic functionality of Eclipse tool. After completing this tutorial, you will find yourself at a moderate level of expertise in using Eclipse IDE from where you can take yourself to next levels. PrerequisitesWe assume you are going to use Eclipse IDE to handle all levels of Java projects development. So it will be good if you have knowledge of software development using any programming language specially Java programming.Copyright & Disclaimer© Copyright 2015 by Tutorials Point (I) Pvt. Ltd.All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book can retain a copy for future reference but commercial use of this data is not allowed. Distribution or republishing any content or a part of the content of this e-book in any manner is also not allowed without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or inthistutorial,******************************************iT able of ContentsAbout the Tutorial (i)Audience (i)Prerequisites (i)Copyright & Disclaimer (i)Table of Contents .................................................................................................................................... i i 1.OVERVIEW (1)What is Eclipse? (1)Licensing (1)Eclipse Releases (1)2.INSTALLATION (3)Downloading Eclipse (3)Installing Eclipse (3)Launching Eclipse (4)3.EXPLORE WINDOWS (5)Parts of an Eclipse Window (5)Using Multiple Windows (6)4.EXPLORE MENUS (7)Typical Eclipse Menus (7)Brief Description of Menus (8)Customizing Menus (8)5.EXPLORE VIEWS (9)About Views (9)Organizing Views (9)Moving Views (9)Creating View Folders (10)Opening a view (10)6.PERSPECTIVES (13)What is a Perspective? (13)Opening a Perspective (13)Switching between Perspectives (13)Closing a Perspective (14)Customizing a Perspective (14)7.WORKSPACES (16)About Eclipse Workspace (16)UI Elements for Managing the Workspace (16)8.CREATE JAVA PROJECT (18)Opening the New Java Project wizard (18)Using the New Java Project wizard (18)Viewing the Newly Created Project (20)9.CREATE JAVA PACKAGE (21)Opening the New Java Package wizard (21)Using the New Java Package Wizard (21)Viewing the Newly Created Package (22)10.CREATE JAVA CLASS (23)Opening the New Java Class Wizard (23)Using the New Java Class Wizard (23)Viewing the Newly Created Java class (24)11.CREATE JAVA INTERFACE (25)Opening the New Java Interface Wizard (25)Using the New Java Interface Wizard (25)Viewing the Newly Created Java Interface (26)12.CREATE XML FILE (27)Opening the New XML File wizard (27)Using the New XML File wizard (28)Viewing the Newly Created XML File (29)13.JAVA BUILD PATH (30)Setting the Java Build Path (30)14.RUN CONFIGURATION (31)Creating and Using a Run Configuration (31)15.RUNNING A PROGRAM (33)Running a Java Program (33)16.CREATE JAR FILES (35)Opening the Jar File wizard (35)Using the Jar File wizard (35)17.CLOSE PROJECT (37)Why Close a Project? (37)How to Close a Project? (37)Closed Project in Package Explorer (38)18.REOPEN PROJECT (39)Reopening a Closed Project (39)19.BUILD PROJECT (40)Building a Java Project (40)20.DEBUG CONFIGURATION (42)Creating and Using a Debug Configuration (42)21.DEBUGGING A PROGRAM (44)Debugging a Java Program (44)22.PREFERENCES (48)Setting Preferences (48)23.CONTENT ASSIST (50)Using Content Assist (50)24.QUICK FIX (52)Using Quix Fix (52)25.HOVER HELP (54)Using Hover Help (54)26.SEARCH MENU (56)Searching the Workspace (56)27.NAVIGATION (58)Navigating the Eclipse Workspace (58)Open Type (58)Open Type in Hierarchy (60)Open Resource (61)28.REFACTORING (63)Refactoring using Eclipse (63)29.ADD BOOKMARKS (64)About Bookmarks (64)Adding a Bookmark (64)Opening the Bookmarks View (64)Using the Bookmarks View (65)30.TASK MANAGEMENT (66)Managing Tasks (66)Opening the Tasks View (67)Using the Tasks View (67)31.INSTALL PLUGINS (69)Locating and Installing Plug-ins (69)32.CODE TEMPLATES (73)Using Code Templates (73)Modifying/Adding code templates (74)33.SHORTCUTS (75)About Shortcuts (75)34.RESTART OPTION (78)Restarting Eclipse (78)35.TIPS & TRICKS (79)36.WEB BROWSERS (81)Internal Web Browser (81)Eclipse 7What is Eclipse?In the context of computing, Eclipse is an integrated development environment (IDE) for developing applications using the Java programming language and other programming languages such as C/C++, Python, PERL, Ruby etc.The Eclipse platform which provides the foundation for the Eclipse IDE is composed of plug-ins and is designed to be extensible using additional plug-ins. Developed using Java, the Eclipse platform can be used to develop rich client applications, integrated development environments, and other tools. Eclipse can be used as an IDE for any programming language for which a plug-in is available.The Java Development Tools (JDT) project provides a plug-in that allows Eclipse to be used as a Java IDE, PyDev is a plugin that allows Eclipse to be used as a Python IDE, C/C++ Development Tools (CDT) is a plug-in that allows Eclipse to be used for developing application using C/C++, the Eclipse Scala plug-in allows Eclipse to be used an IDE to develop Scala applications and PHPeclipse is a plug-in to eclipse that provides complete development tool for PHP.LicensingEclipse platform and other plug-ins from the Eclipse foundation is released under the Eclipse Public License (EPL). EPL ensures that Eclipse is free to download and install. It also allows Eclipse to be modified and distributed.Eclipse ReleasesEvery year, since 2006, the Eclipse foundation releases the Eclipse Platform and a number of other plug-ins in June.1.Eclipse8Eclipse 9Downloading EclipseYou can download eclipse from /downloads/. The download page lists a number of flavors of eclipse.The capabilities of each packaging of eclipse are different. Java developers typically use Eclipse Classic or Eclipse IDE for developing Java applications.The drop down box in the right corner of the download page allows you to set the operating system on which eclipse is to be installed. You can choose between Windows, Linux and Mac. Eclipse is packaged as a zip file.Installing EclipseTo install on windows, you need a tool that can extract the contents of a zip file. For example you can use:∙7-zip ∙PeaZip ∙ IZArcUsing any one of these tools, extract the contents of the eclipse zip file to any folder of your choice.2.Launching EclipseOn the windows platform, if you extracted the contents of the zip file to c:\, then you can start eclipse by using c:\eclipse\eclipse.exeWhen eclipse starts up for the first time it prompts you for the location of the workspace folder. All your data will be stored in the workspace folder. You can accept the default or choose a new location.1011If you select "Use this as the default and do not ask again", this dialog box will not come up again. You can change this preference using the Workspaces Preference Page. See the Preference tutorialpage for more details.Eclipse 12Parts of an Eclipse WindowThe major visible parts of an eclipse window are:∙Views ∙Editors (all appear in one editor area) ∙Menu Bar ∙ ToolbarAn eclipse perspective is the name given to an initial collection and arrangement of views and an editor area. The default perspective is called java. An eclipse window can have multiple perspectives open in it but only one perspective can be active at any point of time. A user can switch between open perspectives or open a new perspective. A perspective controls what appears in some menus and tool bars.3.EclipseA perspective has only one editor area in which multiple editors can be open. The editor area is usually surrounded by multiple views. In general, editors are used to edit the project data and views are used to view the project metadata. For example, the package explorer shows the java files in the project and the java editor is used to edit a java file.The eclipse window can contain multiple editors and views but only one of them is active at any given point of time. The title bar of the active editor or view looks different from all the others.The UI elements on the menu bar and tool bar represent commands that can be triggered by an end user.Using Multiple WindowsMultiple Eclipse Windows can be open at the same time. To open a new window, click on the Windows menu and select the New Window menu item.Each window can have a different perspective open in them. For example you could open two Eclipse windows one in the Java perspective and the other in the Debug perspective. The window showing the Java perspective can be used for editing the java code and the window showing the debug perspective can be used for debugging the application being developed.13Eclipse 14T ypical Eclipse MenusThe typical menus available on the menu bar of an Eclipse window are:∙File menu ∙Edit menu ∙Navigate menu ∙Search menu ∙Project menu ∙Run menu ∙Window menu ∙ Help menu4.Plug-ins can add new menus and menu items. For example when the java editor is open, you will see the Source menu and when the XML editor is open, you will see the Design menu. Brief Description of Menus15Customizing MenusThe visible menu items on a menu depend on the installed plug-ins and customization done using the Customize Perspective dialog box.16Eclipse 17About ViewsEclipse views allow users to see a graphical representation of project metadata. For example the project navigator view presents a graphical representation of the folders and files associated with a project and properties view presents a graphical representation of an element selected in another view or editor.An eclipse perspective can show any number of views and editors. All editor instances appear in a single editor area, whereas views are placed inside view folders. A workbench window can display any number of view folders. Each view folder can display one or more views. Organizing ViewsThe following picture shows four views arranged in a view folder.The picture given below shows the same four views arranged in two view folders.5.Moving ViewsTo move a view from one view folder to another, just click on the view title and drag to the title bar area of another view folder. The green line shown below is a result of dragging the title bar of the Properties view from one view folder to the title bar area of another view folder. The Properties view can be moved to where the green line is by releasing the mouse button and sending out a drop event.Creating View FoldersView folders can be dynamically created by dragging the title bar of a view to anywhere outside the editor area and title bar of another view folder. As you drag the title bar around, green lines will indicate where exactly the new view folder will be created.Moving the drag icon to the bottom of a window allows you to create a view folder that spans the entire width of the window. Moving the drag icon to the left or right edge of window allows you to create a view folder that spans the entire height of the window.18Opening a viewTo open a view, click on the Window menu and select the Show View menu item.19Clicking on the Other menu item brings up the Show View dialog box that allows you to locate and activate a view.20The views are organized by category. To quickly locate a view, just type the name of a view into the filter text box. To open a view, select it and click on the OK button. The subsequent pages of this tutorial introduce you to a number of useful views.21End of ebook previewIf you liked what you saw…Buy it from our store @ https://22。
1.安装windowbuilder:awt插件/windowbuilder/WB/release/R201106211200/3.7/ 2.打开3.4.5.6.7.8.8.开发简介:SWT Designer 是一种功能强大且容易使用的基于Eclipse SWT技术的图形用户界面设计工具,是一个很好的Eclipse的界面开发插件包。
利用SWT Designer 的可视化界面,只需采用拖拉操作,就可以很快地在窗体上创建各种组件,设计出来的窗体和组件的外观和操作系统平台下其他软件的外观相似,具有本机系统的风格。
SWT Designer 可以自动生成Java代码,利用它的属性编辑器还可以改变组件的各种属性,使SWT界面开发变得非常容易。
1.SWT Designer 的下载和安装SWT Designer 有多个版本,要和相应的Eclipse版本相匹配。
我使用的是Designer_v6.7. 0_for_Eclipse3.2.zip。
安装步骤如下:1.1 下载下载版本:Designer_v6.7.0,文件:Designer_v6.7.0_for_Eclipse3.2.zip,下载地址:大家自己搜下,呵呵。
1.2 安装Designer_v6.7.0_for_Eclipse3.2.zip解压缩到Eclipse的安装目录中。
安装结束后,启动E clipse,在主菜单中选择【文件】→【新建】→【项目】,如果在弹出的“新建项目”对话框中多了一个“Designer”项,则表示SWT Designer 安装成功。
如图1所示。
上面已讲述,这里不多谈。
下面讲一个操作实例:在窗体中加入组件加入2 个标签组件(Label)、2 个文本框组件(Text)和2 个按钮组件(Button),如图4所示。
if(text.getText()!=""|text_1.getText()!="")//调用JFace的信息对话框显示登录信息MessageDialog.openInformation(shell,"登录信息","欢迎"+text.getText()+"进入系统!"); else//调用JFace的错误对话框显示出错信息MessageDialog.openError(shell,"错误","用户名或密码为空,请重新输入!");由于用到了JFace的对话框,在程序的前面要引入相应的包:import org.Eclipse.jface.dialogs.*;输入密码时要在密码框显示“*”,需要添加SWT.PASSWORD选项:final Text text_1=new Text(shell,SWT.BORDER|SWT.PASSWORD);import org.Eclipse.swt.SWT;import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Button;import org.eclipse.swt.widgets.Display;import bel;import org.eclipse.swt.widgets.Shell;import org.eclipse.swt.widgets.Text;import org.eclipse.jface.dialogs.*;public class login {private Text text_1;private Text text;protected Shell shell;/** *//*** Launch the application* @param args*/public static void main(String[] args) {try {login window = new login();window.open();} catch (Exception e) {e.printStackTrace();}}/** *//*** Open the window*/public void open() {final Display display = Display.getDefault();createContents();shell.open();yout();while (!shell.isDisposed()) {if (!display.readAndDispatch())display.sleep();}}/** *//*** Create contents of the window*/protected void createContents() {shell = new Shell();shell.setSize(411, 359);shell.setText("SWT Application");text = new Text(shell, SWT.BORDER);text.setBounds(197, 109, 142, 25);text_1 = new Text(shell, SWT.BORDER|SWT.PASSWORD);text_1.setBounds(197, 173, 142, 25);final Button button = new Button(shell, SWT.ABORT);button.setText("提交");button.setBounds(85, 263, 48, 22);final Button button_1 = new Button(shell, SWT.ABORT);button_1.addSelectionListener(new SelectionAdapter() {public void widgetSelected(final SelectionEvent e){}});button_1.setText("取消");button_1.setBounds(247, 263, 48, 22);final Label label = new Label(shell, SWT.NONE);label.setText("用户名");label.setBounds(106, 112, 48, 22);final Label label_1 = new Label(shell, SWT.NONE);label_1.setText("密码");label_1.setBounds(106, 176, 48, 25);button.addSelectionListener(new SelectionAdapter() {public void widgetSelected(final SelectionEvent e){if(text.getText()!=""|text_1.getText()!="")//调用JFace的对话框显示登录信息MessageDialog.openInformation(shell,"登录信息","欢迎"+text.getText()+"进入系统!");else//调用JFace的对话框显示出错信息MessageDialog.openError(shell,"错误","用户名或密码为空,请重新输入!");}});}}开发实例3:开发环境Eclipse3.2,英文版。
使⽤eclipse开发可视化界⾯windowsbuilder
这是我以前在百度⽂库写的⼀篇⽂章,主要讲解在eclipse中安装windowbuder插件让java也能像c++那样进⾏可视化开发,废话不多说,直接开始
Window builder安装
然后右键对应版本后⾯的link,复制链接地址
点击help----->inseal new sol...... 下⾯图⽚
点击后把复制的地址粘贴在框中
全部选中后点next
等待安装完成,时间较长
⽤法
正常创建java⼯程和包,创建图形界⾯时如下,点击other
选择window。
然后点击 finish
在name中填写类名
点击design进⼊设计图形
布局⽅式最好选择这个,可以根据坐标选择部件位置,拖到哪就放到哪
设置时点⼀下absolute ... 然后再画布上点⼀下
点击部件后⿏标移动到画布上出现部件,单击放在⿏标指针位置
Jbutton部件双击进⼊源码,在指针所在位置编写按钮点击事件执⾏的代码
Lable textfield等部件添加⿏标或键盘事件
上图的key和mouse分别为⿏标事件和键盘事件,点击右边最上⾯⼀个进⼊代码中编写事件执⾏的代码。
创建⼀个⾯板bb
在⾥⾯放⼊三个按钮
把这个⾯板添加到主页⾯中
在initialize⽅法中创建bb()类的对象,并设置位置和⼤⼩进⼊画布查看
⾃⼰定义的⾯板已经添加到主⾯板中了。
用Eclipse进行可视化Java界面设计2005-04-01 11:58作者:陈先波出处:csdnblog责任编辑:方舟前言最近,Eclipse开源项目终于推出了期待已久的Visual Editor Project(VEP)。
VE项目使得功能强大的eclipse平台在java开发方面又增加了一个可视化java组件开发利器。
它让java开发者再也不用依赖其它的IDE产品来做GUI界面方面的工作。
所有的开发,从应用程序界面到业务逻辑的开发,现在都可以在eclipse平台上完成。
本文将引导开发者如何安装配置并使用Visual Editor。
关于Visual Editor开始介绍之前,来看一个笔者用Visual Editor(以下简称VE)设计的一个java程序界面:怎么样,其可视化的界面设计,一点也不逊于其它的Java可视化界面开发工具。
Visual Editor是一个开源的eclipse编辑器。
它同JDT、PDE等其它eclipse的工具项目一样,是一个全新的eclipse工具项目。
它可以进行可视化的编辑java GUI程序,也能编辑可视化的Java Bean组件。
它能与eclipse的Java Editor集成在一起,当在Visual Editor 中编辑图形界面时,会立即反馈到java Editor中的代码。
反之亦然。
VE是一个可视化开发的一个framework,当前版本的VE是0.5.0RC1版,本版本的VE支持Swing和AWT的可视Java组件开发。
由于这个framework设计的具有通用性,它也可以很容易的实现C++或其它语言下可视化开发。
其将来的版本(从1.0开始),将会支持SWT的开发。
更多的关于Visual Editor的信息,请看参考资料的相关链接。
下载与安装由于Visual Editor是用纯java编写的,所以它应该可以在任何操作系统上运行。
但当前的VE版本是0.5.0RC1,只在windows和linux平台上经过测试。
Eclipse插件大观Properties Editor 点击次数:6615Properties Editor 编辑java的属性文件,并可以自动存盘为Unicode格式Colorer Take 点击次数:4102Colorer Take 为上百种类型的文件按语法着色XMLBuddy 点击次数:5464XMLBuddy 编辑xml文件Code Folding 点击次数:3136Code Folding 加入多种代码折叠功能(比eclipse自带的更多)Easy Explorer 点击次数:2469Easy Explorer 打开在eclipse中选定文件所在的目录。
Fat Jar 点击次数:3618Fat Jar 打包插件,可以方便的完成各种打包任务,可以包含外部的包等RegEx Test 点击次数:2253RegEx Test 测试正则表达式Jigloo GUI Builder 点击次数:4166Jigloo GUI Builder JAVA的GUI编辑插件Profiler 点击次数:2623Profiler 性能跟踪、测量工具,能跟踪、测量BS程序AdvanQas 点击次数:1201AdvanQas 提供对if/else等条件语句的提示和快捷帮助(自动更改结构等)Log4E 点击次数:3340Log4E Log4j插件,提供各种和Log4j相关的任务,如为方法、类添加一个logger等VSSPlugin 点击次数:2935VSSPlugin VSS插件Implementors 点击次数:2179当追踪方法代码时,Eclipse默认是转到方法的接口类,而接口中是只有方法名称没有具体的实现代码,此插件提供了追踪到具体实现类的实现代码的功能。
Call Hierarchy 点击次数:1595Call Hierarchy 显示一个方法的调用层次EclipseTidy 点击次数:2369EclipseTidy基于HTML Tidy提供校验和格式化HTML/XML文件的功能Checkclipse 点击次数:2527Checkclipse 检查代码的风格、写法是否符合规范Hibernate Synchronizer 点击次数:14526Hibernate Synchronizer Hibernate插件,自动映射等VeloEclipse 点击次数:3328Velocity插件在线更新地址: http://log4e.jayefem.de/updateEditorList 点击次数:1161方便的列出所有打开的EditorMemoryManager 点击次数:2007内存占用率的监视TomcatPlugin 点击次数:7280支持Tomcat插件lomboz 点击次数:9638Lomboz是Eclipse的一个J2EE的插件,它将很多Java应用服务器、J2EE组件和Web应用开发集成到Eclipse 中,可以帮助Java开发者使用Eclipse建立、测试、部署J2EE应用。
课题:第一章 Java Web概述【教学目标】掌握JSP运行环境的搭建,能进行简单的JSP程序编写与运行。
【教学重点】Eclipse+Dreamweaver工具、项目的导入、导出、发布打包【教学难点】Eclipse+Dreamweaver工具、项目的导入、导出、发布打包【教学方法】讲解、讨论【教学地点】教学楼、综合楼【课时安排】4课时【教学过程】1.1 配置JSP运行环境1.1.1 任务描述与实现正确安装Tomcat服务器,并显示其欢迎页面。
如图1-1所示。
图1- 1 使用Tomcat欢迎页面实现过程:1.安装JDK安装Tomcat服务器前首先安装JDK(Java Development Kit),其包括了Java运行环境,Java 工具和Java基础的类库。
目前,提供下载的最新版本为JDK7。
读者可到官方网站下载,下载地址为/technetwork/java/javase/downloads/index.html。
下载后双击安装,画面如图1-2所示,按“下一步”操作直到完成。
图1- 2 JDK安装界面2.安装TomcatTomcat官方网站下载地址:。
本书采用的版本是Tomcat-7.0.20。
下载后,双击安装,如图1-3所示。
点击Next到第一步,进行安装组件选择,如图1-4所示。
第二步选择路径,按照系统默认路径即可。
第三步为配置Tomcat端口信息和账号信息,如图1-5所示,按照实际配置即可。
第四步为选择JDK的安装路径,如图1-6所示,选择在之前第1步操作中安装的JDK所在的位置。
之后单击“Next”开始安装。
安装完毕后,提示安装完成,如图1-7所示。
单击“Finish”完成Tomcat的安装。
安装完成之后,在程序菜单中可以看到Tomcat的选项,如图1-8所示。
点击Monitor Tomcat,可在任务栏看到Tomcat的服务图标,如图1-9所示,双击该图标,弹出如图1-10所示的Tomcat 启动界面,在此界面中可以选择启动或停止Tomcat服务。
最近在客户端软件开发过程中,使用到了Eclipse RCP的若干技术,有种相见很晚的感觉。
尽管自己在日常开发中也使用了SWT中的若干技术,在运用了Theme之后看起来也让人眼前一亮,但是比起RCP 就相当于闭门造车了,例如下面两幅图片,就是SWT技术和RCP 技术开发出的不同界面,后者看起来是不是很炫呢,用流行的话来讲,就是使用户的体验更rich了,呵呵。
SWT界面:Eclipse RCP界面:好了,既然Eclipse RCP开发出的界面如此漂亮,那我们就可以借助Eclipse RCP平台中各类UI组件来改善应用程序上的UI缺陷,通过RCP平台上的各类丰富的GUI视图,来打造赏心悦目的应用程序。
但是在RCP开发的过程中,UI视图之间是相互依赖的,需要进行交互,目前国内教程对这一步骤往往语焉不详,下文就以实例的形式详细介绍Eclipse RCP View视图之间的交互机制,并总结了开发过程中的一些注意事项,避免大家绕了弯路,呵呵。
(一)下载最新的Eclipse RCP开发环境开发RCP的首要前提是下载RCP开发环境,从/上可以下载,下载之后是个zip格式文件,解压到任何目录下都可以直接运行,前提是装好jdk。
在Eclipse的官方网站上,针对不同的开发环境,已经为我们打好了不同的package,只要下载专门用来开发RCP的package即可。
当然如果你已经安装了Eclipse普通开发环境,想增加RCP相关的开发功能,需要通过Eclipse的update功能来添加就可以了,不过后者采用在线安装的方式,容易引起packge插件下载不全,导致开发时出现莫明其妙的错误,因此推荐第一种方案。
(二)新建并运行Eclipse RCP项目Eclipse安装并启动完毕之后,我们可以以插件的形式新增一个RCP模块,在该模块的基础上再添加不同的视图,这样就为下一步打下了良好的基础:在Eclipse的Package Explorer中单击右键,选择菜单第一项“new”,在弹出的子菜单中选择“other”,在对话框中如下图选择:在弹出对话框的“project name”栏中填入自己的项目名称,例如“hellorcp“,其余选项保持默认状态,点击下一步,在Plugin content对话框中“Rich Client Application”中,选择"YES",如下图所示:选择YES表示除了新建一个插件之外,还愿意将其转换成一个RCP应用,以便以后脱离Eclipse开发环境而独立部署,而插件是不能独立运行的,必须依附Eclipse而运行。
java也能写出漂亮的界⾯(Java开源Swing外观)Substance look & feel这个项⽬的⽬的是提供⼀个流⾏的外观(look & feel)。
这个外观(look & feel)联合了Windows XP和MacOS 10.4最好的特性并且需要JDK 5.0以上。
JGoodies look & feelJGoodies look&feels让你的Swing应⽤程序与applets看起来更漂亮.屏幕截图如下:Smooth Metal look & feel屏幕截图如下:Napkin look & feel截图如下:Liquid look & feelMetouia look & feelOffice 2003 & XP look & feel3D look & feel3D Look&Feel是轻量级的.pgs look & feelPgsLookAndFeel是⼀个漂亮的,跨平台的Swing外观.GTK/SwingGTK/Swing是⼀个可插⼊的Swing外观.它尽可能地模仿并接近默认的GTK+.l2fprod-commonSwing已经构建很多组件,但是还有⼀些⽐较流⾏的组件没有提供.这个开源项⽬刚好提供这些少掉的组件.l2fprod-common提供的组件有:PropertySheet,collapsible task pane,button bar,font chooser,directory chooser.以下是其中⼀个组件.Oyoaha look & feelOyoaha look & feel现在也是⼀个开源的项⽬.它基于apache-like license发布.Compiere LooksCompiere Looks是⼀个3D color,它扩展了Java Metal pluggable Look and Feel。
ECLIPSE介绍Eclipse是一个开源的集成开发环境(IDE),主要用于Java开发。
它是由Eclipse基金会开发并维护的,可以在多个操作系统上运行,如Windows,MacOS和Linux。
Eclipse最初是为Java开发而设计的,但它已经延伸到了其他语言,如C,C++,PHP,Python等。
它提供了许多功能强大的工具和插件,以帮助开发人员在一个集成的环境中完成开发工作。
Eclipse的界面简洁、直观,工具和视图可以通过拖拽和调整大小来自定义。
它采用了插件体系结构,使得开发者可以根据需求随时添加或删除工具和功能。
这使得Eclipse成为一个高度可扩展的IDE,可以满足各种不同的开发需求。
Eclipse还提供了源代码管理(SCM)工具的集成,比如Git,Subversion等。
这使得开发人员可以轻松地管理和共享他们的代码库,并与团队成员进行协作开发。
Eclipse还支持项目管理工具,如Maven和Ant,以帮助开发人员轻松构建和部署他们的应用程序。
Eclipse的一个主要特点是它的插件生态系统。
有成千上万的第三方插件可供选择,从而扩展了Eclipse的功能。
这些插件包括代码分析工具,测试框架,数据库管理工具等。
开发人员可以根据自己的需求选择并安装这些插件,使得Eclipse成为一个高度定制化的开发环境。
与其他IDE相比,Eclipse最大的优势之一是它的社区支持。
Eclipse拥有一个庞大的开发者社区,他们为Eclipse开发插件和工具。
开发人员可以通过访问Eclipse官方网站和论坛,获得帮助和支持。
此外,Eclipse还定期发布更新和修补程序,以确保IDE的稳定性和安全性。
前言最近,Eclipse开源项目终于推出了期待已久的Visual Editor Project(VEP)。
VE项目使得功能强大的eclipse平台在java开发方面又增加了一个可视化java组件开发利器。
它让java开发者再也不用依赖其它的IDE产品来做GUI界面方面的工作。
所有的开发,从应用程序界面到业务逻辑的开发,现在都可以在eclipse平台上完成。
本文将引导开发者如何安装配置并使用Visual Editor。
关于Visual Editor开始介绍之前,来看一个笔者用Visual Editor(以下简称VE)设计的一个java程序界面:怎么样,其可视化的界面设计,一点也不逊于其它的Java可视化界面开发工具。
Visual Editor是一个开源的eclipse编辑器。
它同JDT、PDE等其它eclipse的工具项目一样,是一个全新的eclipse工具项目。
它可以进行可视化的编辑java GUI程序,也能编辑可视化的Java Bean组件。
它能与eclipse的Java Editor集成在一起,当在Visual Editor中编辑图形界面时,会立即反馈到java Editor 中的代码。
反之亦然。
VE是一个可视化开发的一个framework,当前版本的VE是0.5.0RC1版,本版本的VE支持Swing 和AWT的可视Java组件开发。
由于这个framework设计的具有通用性,它也可以很容易的实现C++或其它语言下可视化开发。
其将来的版本(从1.0开始),将会支持SWT的开发。
更多的关于Visual Editor的信息,请看参考资料的相关链接。
下载与安装由于Visual Editor是用纯java编写的,所以它应该可以在任何操作系统上运行。
但当前的VE版本是0.5.0RC1,只在windows和linux平台上经过测试。
所以如果你使用的是这两种操作系统之外的其它操作系统,你应该先阅读VE的readme文件,安装和使用VE前,必须先安装以下版本的eclipse和相关支持类库:Eclipse build 2.1.2 (build page) (download zip)EMF build 1.1.1: (build page) (download zip)GEF Build 2.1.2: (build page) (download zip)为了方便中国的开发者,eclipse也提供了一个中文语言包,下载安装后,elcipse环境将变成全中文的界面。
在本文中,笔者用的eclipse也安装了此中文语言包。
之后就可以从以下地址下载Visual Editor 了:/vep….下载后的VE是一个zip档案,请将其压缩包中plugins和features目录下的内容解压到eclipse安装目录的相应目录中即可。
如果你的eclipse是运行着的,请关闭并重新启动eclipse。
开始一个设计任务现在,所有程序安装完成,笔者将用一个例子,来讲解Visual Editor的使用。
在这个例子中,笔者要设计一个邮件发送面板,下面是它的草图:此面板包括发送人,接收人,邮件主题,邮件内容以及发送和清除按钮,进入Visual Editor启动eclipse平台。
刚开始,你可能觉得eclipse并没有什么变化。
先别急,请新建一个项目,点击"文件"菜单下的"新建"子菜单,选择并建立一个新的"java项目"。
然后在工具栏上的"新建Java类" 图标上,点击右边的小箭头,将展开如下图的菜单:在此菜单上,多了一个"Visual Calss"的子菜单,这就是进入Visual Editor的入口之一。
点击"Visual Class",弹出如下的对话框:在此对话框中,要求输入类的名称(如标记○1)位置),在这里我们输入"MessagePanel",以及你想要继承的可视类(如标记○2位置)。
你可以选择继承来自swing或AWT的任何界面组件,如要继承其它类型的类,请选择"other"并点击"浏览"按钮来选择你要继承的类。
在此处,我们选择"panel"和Swing选项,继承JPanel,然后点击"完成"按钮,大家就可以见到Visual Editor的界面了:由于eclipse工作台高度的可定制性,读者现在看到的界面并非VE初始的布局,而是经过笔者按喜好的方式重新布局过的透视图,但是这并不会影响读者理解本文内容。
如图中1所示,是VE的工具面板,提供"选取"、"框选"等选择工具。
还有Swing组件,Swing容器,Swing菜单以及AWT控件设计工具。
在面板下方有"Design"和"Source"两个页签,用来切换设计界面和Java源代码视图。
图中2是VE的工具栏,包括工具面板中的一些常用按钮。
图中3是"Java Beans"视图和"属性"视图,两个视图可以切换显示。
"Java Beans"视图用树形结构即时显示设计中用到的各种Java Bean组件层次。
而"属性"视图显示显示当前所选中的Java bean组件的属性值列表,你可以在此列表中编辑各项Java Bean的属性值。
图中灰色矩形区域即是我们最开始选择的JPanel,所有的工作就从它开始。
摆设Swing组件做过Swing GUI界面设计的人都知道,Java应用程序界面上的元素位置是用LayoutManager来管理的。
JPanel的预设布局管理器是FlowLayout。
VE目前支持所有的传统的布局管理器(这里所指的传统布局管理器是指JDK1.4之前的布局管理器。
可惜的是VE目前还不支持从JDK1.4开始有的SpringLayout)。
要设置JPanel的layout,请先在设计界面中选中JPanel,再切换到"属性"视图,找到"layout"属性,如下图所示:图中显示了JPanel的预设LayoutManager。
在"layout"属性的右边,可以通过点击组合框来指定不同类型的LayoutManager。
不同的LayoutManager会在属性编辑器中显示不同的参数,如果选择GridLayout,属性编辑器中的layout属性将显示另外几种不同的参数,如下图如示:先前的FlowLayout的三个参数alignment, horizontal gap和vertical gap变成了GridLayout的另外四种参数:columns, horizontal gap, rows, vertical gap。
为了方便设计,笔者在这个例子中将采用null,即不用任何LayoutManager来设计界面。
布局设置好后,就可以在JPanel上摆置各种Swing组件了。
按照我们最开始设计的草图,界面上要摆上四个Label:From, To, Subject, Message。
以及四个文本组件,其第四个应该是TextArea, 用于编辑多行文本。
我们在工具面板上选好相关组件,然后在JPanel上拖选出一个矩形,组件即按相应大小和位置显示在此矩形区域。
再在"属性"视图中编辑每个JLabel和JButton的"text"属性为相应的值。
现在来看看下面笔者"画"出来的界面:看看,设计的如何?笔者不是画家,"画"出来的界面显得有些凌乱。
没关系,VE也提供一些工具按钮来让我们调整各个组件的位置。
请点击VE工具栏上的"Show alignment window"按钮:显示如下图的视窗:通过此视窗,可以将所选组件向上下左右各个方向对齐。
还可以使所选组件具有相同高度和宽度。
来看看下图经过调整位置后的界面布局:现在看起来是不是美观多了?添加事件处理经过前面的步骤,VE的可视化设计的任务就基本上完成了。
在我们设计的界面中,有"Send"和"Clear"按钮。
我们再来看看VE是如何为它们添加事件处理的。
在设计界面的"Send"按钮上点击鼠标右键,弹出菜单,如下图:在"Event"菜单项中,可以看到一个"actionPerformed"事件。
如果要添加其它类型的事件,可以点击"Add Events"选择其它类型的事件。
我们点击"actionPerformed"事件后,在"Java Beans"视图的"jButton-"Send""组件下面,多了一个"actionPerformed"事件类型,如下图所示:在"Java Beans"视图中,选中"actionPerformed"事件,再VE的窗口中,从"Design"切换到"Source"视图。
在上图标记1的代码区域,就是我们刚刚添加的按钮事件。
笔者在事件中调用了一个send方法,如图中标记2代码区域。
具体的发送邮件的代码笔者在这里就不实现了。
同样的方法,一样可以为另一个按钮"Clear"添加事件。
在程序中使用自定义的组件在前面我们设计好了自己的Java组件,现在我们来看看如何在自己的程序中――一个窗口中来调用这个组件。
使用前面介绍的方法,在工具栏上点击"新建Java类"按钮,建立一个JFrame的Visual Class类。
你也可以在通过菜单"文件"->"新建"->"Visual Class"来寻一个JFrame类。
在这里,我们将这个类命名为"MyApp"。
当VE窗口出现时,可以看到一个空白的JFrame显示在设计视图中。
此时,点击VE的工具面板上的" Choose Bean"按钮,然后在弹出的对话框中输入我们设计的Java组件的类名"MessagePane",再点击"确定"。
这时,当我们的鼠标移到JFrame上时,JFrame会用绿色的线条切分成五份,如下图所示:这是因为JFrame的预设LayoutManager是BorderLayout,在VE中,如果在工具面板上选好Java 组件,当鼠标移到有特定LayoutManager的容器组件上时(在上图中容器组件是一个JFrame),VE会用适当的形式指示你当前鼠标悬停的位置。