在SWT中设置table的行高
来源:互联网 发布:网页美工面试问题 编辑:程序博客网 时间:2024/05/08 13:01
转自:http://blog.csdn.net/zankuro/archive/2007/02/08/1505274.aspx
不过就算我只在item1上setImage,item2和item3行高也会一起改变,没法单独指定某一行的高度。
第2种方法相对正式一点,是通过捕获SWT.MeasureItem事件来定制单元格的高度和宽度,具体内容可参看原文Custom Drawing Table and Tree Items,代码演示如下:
同样的,这个方法也不能为每一行指定不同的行高,在原文中也说了"All items in a table have the same height, so increasing the height of a cell will result in the height of all items in the table growing accordingly."。看来这一点在SWT中是做不到了。
前 段时间做Sametime的插件,遇到了需要设置table行高的问题。乍一看,Table和TableItem类中都没有相应的方法可用。于是上网问了 一下google,首先找到了一个比较偏门的方法,就是通过设置指定height的Image来改变行高,代码演示如下:
Display display = new Display();
Shell shell = new Shell(display);
shell.setBounds(10, 10, 200, 250);
Table table = new Table(shell, SWT.NONE);
table.setBounds(10, 10, 150, 200);
table.setLinesVisible(true);
int rowHeight =30;
TableItem item1 =new TableItem(table, SWT.NONE);
item1.setText("item 1");
TableItem item2 =new TableItem(table, SWT.NONE);
item2.setText("item 2");
TableItem item3 =new TableItem(table, SWT.NONE);
item3.setText("item 3");
Image image = new Image(display, 1, rowHeight);
item1.setImage(image);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
Shell shell = new Shell(display);
shell.setBounds(10, 10, 200, 250);
Table table = new Table(shell, SWT.NONE);
table.setBounds(10, 10, 150, 200);
table.setLinesVisible(true);
int rowHeight =30;
TableItem item1 =new TableItem(table, SWT.NONE);
item1.setText("item 1");
TableItem item2 =new TableItem(table, SWT.NONE);
item2.setText("item 2");
TableItem item3 =new TableItem(table, SWT.NONE);
item3.setText("item 3");
Image image = new Image(display, 1, rowHeight);
item1.setImage(image);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
不过就算我只在item1上setImage,item2和item3行高也会一起改变,没法单独指定某一行的高度。
第2种方法相对正式一点,是通过捕获SWT.MeasureItem事件来定制单元格的高度和宽度,具体内容可参看原文Custom Drawing Table and Tree Items,代码演示如下:
Display display = new Display();
Shell shell = new Shell(display);
shell.setBounds(10, 10, 200, 250);
final Table table = new Table(shell, SWT.NONE);
table.setBounds(10, 10, 150, 200);
table.setLinesVisible(true);
final int rowHeight =30;
for (int i = 0; i < 5; i++) {
new TableItem(table, SWT.NONE).setText("item " + i);
}
table.addListener(SWT.MeasureItem, new Listener() {
public void handleEvent(Event event) {
event.height =rowHeight;
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
Shell shell = new Shell(display);
shell.setBounds(10, 10, 200, 250);
final Table table = new Table(shell, SWT.NONE);
table.setBounds(10, 10, 150, 200);
table.setLinesVisible(true);
final int rowHeight =30;
for (int i = 0; i < 5; i++) {
new TableItem(table, SWT.NONE).setText("item " + i);
}
table.addListener(SWT.MeasureItem, new Listener() {
public void handleEvent(Event event) {
event.height =rowHeight;
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
同样的,这个方法也不能为每一行指定不同的行高,在原文中也说了"All items in a table have the same height, so increasing the height of a cell will result in the height of all items in the table growing accordingly."。看来这一点在SWT中是做不到了。
- 在SWT中设置table的行高
- 在SWT中设置table的行高
- 解决SWT中Table行高的问题
- 在swt中使用table
- 在其他类中调用 swt table
- 前端开发中表格table单元格高度或者行高的设置
- SWT学习笔记_1在如何table中动态添加
- SWT - Table的使用
- SWT table 设置行,列背景色,字体色
- swt table中添加入力框
- SWT table中嵌入radioButton
- SWT/JFACE的table中加入控件 事件监听
- 关于在table中设置tr的格式的方法
- 在自定义Table的Selection事件中设置当前行
- 在bootstrap的table表格中,设置文本内容居中
- 在table中给tr设置border的方法
- 在Swing中嵌入SWT的组件
- SWT表格字体的设置(即TableViewer)其实设置的是Table
- windows RMS 部署
- DataBinder.Eval用法
- 软件测试理论
- 一个很不错的pl/sql的高级教程的博客
- AJAXControlToolKit控件入门实例之PopupControl
- 在SWT中设置table的行高
- ASP.NET数据库编程
- 使用ASP.NET 2.0 Profile存储用户信息_2[翻译]
- 性能测试(并发负载压力)测试分析-简要篇
- C#在客戶端和服務端操作Excel文件
- java不规则窗体的构建
- ASP.NET程序中常用的三十三种代码
- Hello GTK
- 参数化模块库(LPM)的使用