第三章 第六节 SWT类的常量与函数
2011-09-10 20:12
274 查看
第六节 SWT类的常量与函数
返回目录SWT类有一堆类级别(class-level)的常量和方法用来简化SWT编程。
没有什么事情阻止您创建一个SWT对象,因为创建一个不会带来任何坏处。SWT类继承于java.lang.Object,它没有定义构造函数,所以默认的构造函数会被调用。然而,一个SWT对象除了继承于java.lang.Object的状态,没有任何状态(state),本质上这些状态也是没什么用的。
SWT类提供了一些有用的方法,像前面提到的,都是静态的(static)。大多数程序不必用到这些方法;它们在表3-6中列出。
表3-6: SWT 的方法
方法 | 说明 |
static void error(int code) | Throws an exception based on code. It's the same as calling static void error(int code, (Throwable) null). |
static void error(int code, Throwable throwable) | Throws an exception based on code. throwable should either be null or the Throwable that caused SWT to throw an exception. code is one of the error constants defined in SWT. |
static String getMessage (String key) | Gets the appropriate National Language Support (NLS) message as a String for key. See java.util.ResourceBundle for more information on NLS. The resource bundle is found in org.eclipse.swt.internal.SWTMessages .properties; see Table 3-7 for the supported keys and corresponding messages. |
static String getPlatform() | Gets the SWT platform name (for example, "win32," "gtk," "carbon"). |
static int getVersion() | Gets the SWT library version number. |
表3-7: SWT消息的键(Key)和值(value)
键 | 值 |
SWT_Yes | Yes |
SWT_No | No |
SWT_OK | OK |
SWT_Cancel | Cancel |
SWT_Abort | Abort |
SWT_Retry | Retry |
SWT_Ignore | Ignore |
SWT_Sample | Sample |
SWT_A_Sample_Text | A Sample Text |
SWT_Selection | Selection |
SWT_Current_Selection | Current Selection |
SWT_Font | Font |
SWT_Color | Color |
SWT_Extended_style | Extended style |
SWT_Size | Size |
SWT_Style | Style |
SWT_Save | Save |
SWT_Character_set | Character set |
SWT_ColorDialog_Title | Colors |
SWT_FontDialog_Title | Fonts |
SWT_Charset_Western | Western |
SWT_Charset_EastEuropean | East European |
SWT_Charset_SouthEuropean | South European |
SWT_Charset_NorthEuropean | North European |
SWT_Charset_Cyrillic | Cyrillic |
SWT_Charset_Arabic | Arabic |
SWT_Charset_Greek | Greek |
SWT_Charset_Hebrew | Hebrew |
SWT_Charset_Turkish | Turkish |
SWT_Charset_Nordic | Nordic |
SWT_Charset_Thai | Thai |
SWT_Charset_BalticRim | Baltic Rim |
SWT_Charset_Celtic | Celtic |
SWT_Charset_Euro | Euro |
SWT_Charset_Romanian | Romanian |
SWT_Charset_SimplifiedChinese | Simplified Chinese |
SWT_Charset_TraditionalChinese | Traditional Chinese |
SWT_Charset_Japanese | Japanese |
SWT_Charset_Korean | Korean |
SWT_Charset_Unicode | Unicode |
SWT_Charset_ASCII | ASCII |
SWT_InputMethods | Input Methods |
在Windows XP下Eclipse 2.1.1中输入这些代码:
System.out.println("Platform: " + SWT.getPlatform());
System.out.println("Version: " + SWT.getVersion());
这些代码会打印:
Platform: win32
Version: 2135
返回目录
相关文章推荐
- 在函数中用const定义的常量在函数结束后内存是否释放了
- [置顶] PHP Math 函数和常量总汇(方便使用)
- 《算法导论》系列课后练习题之-第三章《函数的增长》(下)
- 053day(成员对象和封闭类,常量对象,常量成员函数)
- 关于C++中的常量成员函数
- php 非常有用的高级函数PATH_SEPARATOR常量和set_include_path
- const限定修饰符用法总结(常量,指针,迭代器,函数参数,成员函数)
- 第三章:变量、常量与数据类型
- 第三章:函数
- 第三章 --- 第六节
- swift基础(一) 变量和常量和函数
- 第三章 函数的增长 3.1 渐进记号
- C++必知必会之(10)常量成员函数的含义
- php魔法函数与魔法常量的说明
- C++入门经典 笔记(第三章)变量和常量
- const 常量 解释 引用 函数
- PHP的魔术函数和魔术常量
- php中的注释、变量、数组、常量、函数应用介绍
- C++ 常量指针或者常量引用作为函数参数传递的原因
- PHP 判断常量,变量和函数是否存在