import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
public class Example3 {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
final Color red = display.getSystemColor(SWT.COLOR_RED);
final Color yellow = display.getSystemColor(SWT.COLOR_YELLOW);
final Table table = new Table(shell, SWT.FULL_SELECTION);
table.setHeaderVisible(true);
new TableColumn(table, SWT.NONE).setWidth(100);
new TableColumn(table, SWT.NONE).setWidth(100);
new TableColumn(table, SWT.NONE).setWidth(100);
for (int i = 0; i < 5; i++) {
TableItem item = new TableItem(table, SWT.NONE);
item.setText(0, "item " + i + " col 0");
item.setText(1, "item " + i + " col 1");
item.setText(2, "item " + i + " col 2");
}
table.pack();
/*
* NOTE: EraseItem is called repeatedly. Therefore it is critical
* for performance that this method be as efficient as possible.
*/
table.addListener(SWT.EraseItem, new Listener() {
public void handleEvent(Event event) {
event.detail &= ~SWT.HOT;
if ((event.detail & SWT.SELECTED) == 0) return; /* item not selected */
int clientWidth = table.getClientArea().width;
GC gc = event.gc;
Color oldForeground = gc.getForeground();
Color oldBackground = gc.getBackground();
gc.setForeground(red);
gc.setBackground(yellow);
gc.fillGradientRectangle(0, event.y, clientWidth, event.height, false);
gc.setForeground(oldForeground);
gc.setBackground(oldBackground);
event.detail &= ~SWT.SELECTED;
}
});
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
}
分享到:
相关推荐
swt table 实现换行
SWT Table 单元格编辑实例代码
工具类实现了分页,虽然还有些欠缺,如在搜索栏和导出菜单未考虑分页的情况
SWT表格管理类,包括表头排序事件,table宽度自适应事件,隔行颜色事件
修改类库中的tooltip、单元格的复制与粘贴
基于java语言,应用eclipse SWT类库+Jdbc+SqlServer数据库,实现同一界面展示散点图和数据表格展示,满足跨平台、安全等软件应用需求。
使Excel嵌入到SWT窗口中 使用的Eclipse版本:3.3.1 使用的jdk版本:5.0
SWT中文教程.rar/////SWT中文教程.rar
swt中treeview和tableview实例,有助于理解这两个控件的使用。另外附带html页面。。可读性更强。
SWT插件中文教程SWT常用方法SWT插件中文教程SWT常用方法SWT插件中文教程SWT常用方法SWT插件中文教程SWT常用方法SWT插件中文教程SWT常用方法SWT插件中文教程SWT常用方法
下载后你自己创建一个根目录,把cho4文件夹都导入,配置你的数据库,就可以直接运行,有一点要知道,该小示例中的修改和删除功能都是以获取数据下标为ID进行与数据库操作的,可以参考
下面小编就为大家带来一篇删除table表格行的实例讲解。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
非常不错的java swt 中文文档
SWT配置 SWT配置 SWT配置 SWT配置 SWT配置 SWT配置 SWT配置 SWT配置
NULL 博文链接:https://1299020954.iteye.com/blog/2181896
Eclipse中SWT插件的安装Eclipse中SWT插件的安装
org.eclipse.swt.custom.TableEditor.class org.eclipse.swt.custom.TableTree.class org.eclipse.swt.custom.TableTreeEditor.class org.eclipse.swt.custom.TableTreeItem.class org.eclipse.swt.custom....
rcp开发中用到的swt/Jface组件等 Swt.JFace.in.Action中文版
为表列添加排序功能,列适应表格宽度,添加光棒以及各行颜色差效果,背景颜色,隔行换色
64位windows操作系统使用的SWT库