Eclipse3.2和VE插件安裝實戰(zhàn)攻略
Eclipse3.2和VE插件安裝實戰(zhàn)攻略
早就聽說Eclipse的鼎鼎大名并且領教過了其強大功能,瀏覽了好多關于Eclipse的文章,聽說用SWT,JFace能設計出擁有本地操作系統(tǒng)界面風格的東東,如果在XP上運行,豈不是很讓客戶滿意,近期想要做個桌面系統(tǒng),, 想試一下. 用Eclipse當然就要裝上再說,這兩天我是吃勁了苦頭..., 下載了很多東西,讀了很多文章,終于調(diào)通了,現(xiàn)在給大家分享下.我沒有找到完整的安裝攻略,現(xiàn)在就寫一個最新的.....
建議您先瀏覽下Eclipse網(wǎng)站 http://www.eclipse.org尤其是 Projects 連接, 其中的Eclipse Project, 和 Eclipse Tools Project. Eclipse (Eclipse SDK 最新的是3.2) 是一個平臺,其中的JDT,PDE都是集成在Eclipse下載的,SWT,JFace開發(fā)包也是,不用關心太多,有些文章說的很多,反而讓新手迷惑。
Eclipse Tool Project 主要用到Graphical Editor Framework (GEF) Project, EMF, VE 不要急于下載這些東東,我算是吃勁苦頭...... 用Eclipse當然希望用它的可視化編程(Visual Edit Project) 插件. 現(xiàn)在最新的是 VE
好了,攻略開始.建個下載文件夾. 下載VE(
下載的文件名稱分別為:
eclipse-SDK-3.2-win32
emf-sdo-runtime-
GEF-runtime-3.2
VE-runtime-1.2
VE-SDK-1.2
可以在如下地址下載:
http://download.eclipse.org/tools/ve/downloads/drops/R-1.2-200606280938/index.html
eclipse-SDK-3.2-win32 下載地址:
emf-sdo-runtime-
GEF-runtime-3.2 下載地址:
VE-runtime-1.2 下載地址:
VE-SDK-1.2 下載地址:
解壓縮Eclipse SDK 3.2, 把解壓縮里的 eclipse 文件夾拷貝到F:\hongjun 看看里邊的內(nèi)容,主要是plugins,features 等,解壓縮 emf-sdo-runtime-
到F:\hongjun\emf 文件夾, GEF-runtime-3.2到F:\hongjun\gef,VE-runtime-1.2到F:\hongjun\veruntime,,VE-SDK-1.2到F:\hongjun\ve。在eclipse的links文件夾下(我的是在F:\hongjun\eclipse\links)建立一個ve.start文本文件,輸入內(nèi)容:path=F:\\hongjun\\ve
path=F:\\hongjun\\gef
path=F:\\hongjun\\emf
path=F:\\hongjun\\veruntime
保存完畢。
Eclipse 3.2 需要 JDK
由于運行SWT的程序用到本地庫,所以應該導入SWT的原生包 , 運行程序可以自動找到. 這些問題都困擾了我好長時間. 現(xiàn)在啟動F:\hongjun\eclipse.exe,都OK了 eclipse 能自動認出你的JRE.
實戰(zhàn)! 啟動eclipse,看看MyProject 吧,不錯... 界面很迷人! 新建一個項目 file->New->project 出來項目向?qū)?span lang="EN-US">, 選擇java project. ->next 輸入project Name: MyProject , Eclipse自動給你建個workspace 工作文件夾,你的項目都存在這里的,F:\hongjun\eclipse\workspace 點擊結束. 一個新項目建成了. 添加SWT ToolKit, 菜單Project->Properties 選擇左側(cè)的 Java Build Path 選擇 右側(cè)的 Libraries 標簽頁, 點擊 Add Library 按鈕, 選擇 Standard Widget Toolkit(SWT) 點擊 Next , 選上 Include support for JFace library 結束.這樣就可以使用 SWT Jface控件了. 選中你的project MyProject. 選擇新建圖標按鈕, 上端最左側(cè)的. 選擇 Visual Class ,點擊Next , Source Folder 是缺省的 project folder, package 填入 lihongjun, Name 填入 Hello , 展開左側(cè)的 SWT 選擇 Shell, 勾選上 public static void main(String[] args), Constructors from superclass, Inherited abstract methods. 結束.
Eclipse 自動啟動 VE.... 看看那些窗口... 比較熟悉.. 出現(xiàn)了可視化編輯窗口. 鼠標移到右側(cè)的Palette(豎著的那個)把 一個Label,一個Button, 一個TextArea 放到shell上. 選中Label, 在下側(cè)的Properties屬性欄可以進行設置, >text 填入Label,選中 Button 在下側(cè)的Properties屬性欄可以進行設置, >text 填入Hello everone. 選中 Button 右鍵, events->Add Events . 選擇Mouse ->mouseDoubleClick. 相應的代碼自動產(chǎn)生.也可進行其他的風格設置, 但是如果JDK版本不對則不能操作,有錯。
全部代碼:
package lihongjun;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Text;
public class Hello {
private Shell sShell = null ;
private Label 標簽 = null ;
private Button button = null ;
private Text textArea = null ;
public Hello() {
// TODO Auto-generated constructor stub
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
/* Before this is run, be sure to set up the launch configuration (Arguments->VM Arguments)
* for the correct SWT library path in order to run with the SWT dlls.
* The dlls are located in the SWT plugin jar.
* For example, on Windows the Eclipse SWT 3.1 plugin jar is:
* installation_directory\plugins\org.eclipse.swt.win32_
*/
Display display = Display.getDefault();
Hello thisClass = new Hello();
thisClass.createSShell();
thisClass. sShell .open();
while (!thisClass. sShell .isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
/**
* This method initializes sShell
*/
private void createSShell() {
GridLayout gridLayout = new GridLayout();
gridLayout. numColumns = 1;
sShell = new Shell();
sShell .setText( "Shell" );
sShell .setLayout(gridLayout);
sShell .setSize( new Point(300, 200));
標簽 = new Label( sShell , SWT. NONE );
標簽 .setText( "Label" );
Label filler2 = new Label( sShell , SWT. NONE );
button = new Button( sShell , SWT. NONE );
button .setText( "click me!" );
button .addMouseListener( new org.eclipse.swt.events.MouseAdapter() {
public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e) {
System. out .println( "mouseDoubleClick()" ); // TODO Auto-generated Event stub mouseDoubleClick()
}
public void mouseDown(org.eclipse.swt.events.MouseEvent e) {
System. out .println( "mouseDown()" ); // TODO Auto-generated Event stub mouseDown()
}
});
Label filler = new Label( sShell , SWT. NONE );
Label filler1 = new Label( sShell , SWT. NONE );
textArea = new Text( sShell , SWT. MULTI | SWT. WRAP | SWT. V_SCROLL );
textArea .setText( "Hello ,everyone!" );
}
}
好了,大功馬上告成. 選擇運行圖標, toolBar 上的綠色按鈕旁邊的黑下箭頭.選擇->run.., 選擇左側(cè)的java Application,不一會界面就出來了...., 以后你就可以直接點擊Run圖標,運行這個程序. 點擊Click Me 看看TextArea的變化。
posted on 2006-08-25 20:13 XiaoLi 閱讀(18609) 評論(22) 編輯 收藏 所屬分類: Eclipse