SWT实例学习代码例子 -- 学好swt,色色就可以写桌面应用了
来源:互联网 发布:知乎怎么修改兴趣 编辑:程序博客网 时间:2024/05/08 03:59
包名称 package cn.iamsese.swt.study ;
定义一个类来做运行时的入口,这样可以减少main方法的使用,使自己更能进入SWT的学习
/** * 运行控制器类 */ public class Runner {public static void main(String[] args) {SimpleShell simpleShell = new SimpleShell(ExampleClassName.DefaultWindow);//SimpleShell simpleShell = new SimpleShell(ExampleClassName.ChildShell);}}
定义一个类用于分辨不同的demo例子,使得可以传入不同的构造函数到同一的构造函数处,以后没建立一个新实例,就在其中添加一个常数,使用16进制,因为好标识
/** * 实例类的名字 -- 通过在构造函数中调用不同的参数值来运行不同的实例程序 * cn.iamsese.swt.study * Author: vb2005xu [JAVA菜鸟] */interface ExampleClassName {public final static int DefaultWindow = 0x1 ; //缺省实例public final static int ChildShell = 0x2 ; //子窗口实例}
导入的包 -- 以后按需要会添加
import org.eclipse.swt.* ;import org.eclipse.swt.widgets.*;
每添加一个例子,就在其中添加一些代码,后面会陆续跟新一些模板代码,但是大体东西不变
/** * 所有例子的外壳代码 * cn.iamsese.swt.study * Author: vb2005xu [JAVA菜鸟] */class SimpleShell {private Display display ;private Shell shell ;public SimpleShell(String title){this.display = new Display();this.shell = new Shell(this.display);this.shell.setText(title);this.shell.setSize(500,500);SimpleShellUtil.setShellAtCenter(this.shell);}public SimpleShell(int className){this("第一个SWT例子: cn.iamsese.swt.study.SimpleShell");this.shell.open();switch (className) {case ExampleClassName.ChildShell:this.childShellTest(this.shell);break;default:break;}while(! this.shell.isDisposed()){if ( ! this.display.readAndDispatch() ){this.display.sleep();}}this.display.dispose();}public void childShellTest(Shell shell){//非模态对话框ChildShell child1 = new ChildShell(shell);//模式对话框 -- 只禁用父窗体ChildShell child2 = new ChildShell(shell,SWT.DIALOG_TRIM|SWT.APPLICATION_MODAL);//模式对话框 -- 禁用系统窗体ChildShell child3 = new ChildShell(shell,SWT.DIALOG_TRIM|SWT.SYSTEM_MODAL);}}
代码例子1 -- ChildShell 每个代码例子,基本都是自包含的
/** * 子 窗口实例 * cn.iamsese.swt.study * Author: vb2005xu [JAVA菜鸟] */class ChildShell {public ChildShell(Shell parent){Shell child = new Shell(parent);child.setText("第二个SWT例子: cn.iamsese.swt.study.ChildShell");child.setSize(400,100);child.open();}public ChildShell(Shell parent,int style){Shell child = new Shell(parent,style);child.setText("第二个SWT例子: cn.iamsese.swt.study.ChildShell");child.setSize(400,100);child.open();}}
0 0
- SWT实例学习代码例子 -- 学好swt,色色就可以写桌面应用了
- swt table空间应用实例
- Java桌面应用程序设计新贵:SWT 简介
- Java桌面应用程序设计新贵:SWT 简介
- Java桌面应用程序设计:SWT 简介
- Java桌面应用程序设计新贵:SWT 简介
- swt代码
- SWT学习
- swt 学习
- SWT可以胜任大部分windows桌面程序的开发
- SWT
- SWT
- swt
- swt
- swt
- swt
- swt
- SWT
- 低版本的模拟器
- 上班了还能享受带薪长假,真爽啊 外企就是好啊!
- 矩阵乘法
- LeetCode 136. Single Number
- Linux守护进程的创建方法和步骤
- SWT实例学习代码例子 -- 学好swt,色色就可以写桌面应用了
- 利用Set List Map集合的特点处理重复字符串
- document.execCommand()解析
- Java注解Annotation浅析
- 导出MySql表结构及MySql执行外部SQL脚本
- 终端界面GUI开源项目charva -- 介绍
- java 我行我素换购系统 关键代码
- 实现一个Assert类,用于测试使用
- supermap 缓冲区分析