- 浏览: 551131 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (344)
- ··············未分类············· (33)
- Eclipse 插件 (15)
- EDA 工具 (1)
- Linux/Unix (3)
- Java (43)
- Java Applet (1)
- Java Draw2d (22)
- Java Draw2d version2 (6)
- Java GEF (2)
- Java SWT (21)
- Java SWT Image 图像 (21)
- Java SWT Tree (16)
- Java SWT Table (4)
- Java SWT TableViewer (11)
- Java SWTbot (4)
- Java Test (2)
- Java Thread 多线程 (22)
- Java Zest (5)
- RC2_3S400学习笔记 (16)
- tcl 脚本 (10)
- Verilog (7)
- XML (6)
- 国家 (5)
- 感叹 (4)
- 面试题 (9)
- 生活 (36)
- 足球 世界杯 (8)
- 老公看你的 (3)
- web开发 (1)
- 数据结构——图 (7)
- c language (1)
最新评论
-
zxjlwt:
路过素人派http://surenpi.com
SWT 树的事件 SWT.Selection SWT.CHECK SWT.DefaultSelection -
hj01kkk:
1楼用法正解
JDK 7 中的 Fork/Join 模式 -
fish_no7:
使用 new SortTask().fork()
JDK 7 中的 Fork/Join 模式 -
wpf523:
mark
Java 多线程例子6 线程安全 线程同步 同步代码块 同步函数 -
uniquejava:
以前碰到过,估计是在icu包中实现了双击自动选中一段文本的功能 ...
java.lang.NoClassDefFoundError: com/ibm/icu/text/BreakIterator
源程序来自:snippet77
/******************************************************************************* * Copyright (c) 2000, 2004 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.swt.snippets; /* * Table example snippet: resize columns as table resizes * * For a list of all SWT example snippets see * http://www.eclipse.org/swt/snippets/ */ import org.eclipse.swt.*; import org.eclipse.swt.events.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; public class Snippet77 { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); final Composite comp = new Composite(shell, SWT.NONE); final Table table = new Table(comp, SWT.BORDER | SWT.V_SCROLL); table.setHeaderVisible(true); table.setLinesVisible(true); final TableColumn column1 = new TableColumn(table, SWT.NONE); column1.setText("Column 1"); final TableColumn column2 = new TableColumn(table, SWT.NONE); column2.setText("Column 2"); for (int i = 0; i < 10; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText(new String[] {"item 0" + i, "item 1"+i}); } comp.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { Rectangle area = comp.getClientArea(); Point preferredSize = table.computeSize(SWT.DEFAULT, SWT.DEFAULT); int width = area.width - 2*table.getBorderWidth(); if (preferredSize.y > area.height + table.getHeaderHeight()) { // Subtract the scrollbar width from the total column width // if a vertical scrollbar will be required Point vBarSize = table.getVerticalBar().getSize(); width -= vBarSize.x; } Point oldSize = table.getSize(); if (oldSize.x > area.width) { // table is getting smaller so make the columns // smaller first and then resize the table to // match the client area width column1.setWidth(width/3); column2.setWidth(width - column1.getWidth()); table.setSize(area.width, area.height); } else { // table is getting bigger so make the table // bigger first and then make the columns wider // to match the client area width table.setSize(area.width, area.height); column1.setWidth(width/3); column2.setWidth(width - column1.getWidth()); } } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }
效果图:
上面表格可以随着窗口的大小变化一起变化。
总结:现在看这个程序非常的简单,当时记得一开始想实现这个功能的时候找了半天,老是觉得是不是可以设置一个table的什么参数,就能够自适应了。其实,这里就是没有看清问题的本质,要实现的就是要当窗口变化时,改变table的布局就行,这样就自然有了上面的方法注册窗口或composite的变化就行了。
发表评论
-
定制tooltip
2013-10-06 18:17 712public class HelloToolTip { ... -
java SWT StackLayout
2013-09-16 17:40 818public class UsingStackLayout ... -
JFace snippet
2013-01-31 11:00 1378附件有org.eclipse.jface.snippets, ... -
SWT 中Button和Label重叠放置
2011-12-30 17:18 2673写了一个小例子: public class Snipp ... -
SWT DND的Snippet 和 剪贴板
2011-11-15 19:50 2234链接:http://www.eclipse.org/swt/s ... -
display.getSystemColor 中的颜色
2011-10-28 20:41 1244记得以前好像记录过,就是找不到了。 public c ... -
SWT程序需要导入的jar
2011-10-12 18:04 11491,org.eclipse.swt.win32.x86_xxx ... -
用滚动的字符表示Task的运行,比较ProgressMonitorDialog
2011-08-16 17:55 3189JFace中的提供的ProgressMonitorDialog ... -
SWT 的对话框模式与非模式
2011-05-24 16:03 1959关键字:SWT 对话框 模式 非模式 SWT.MODELESS ... -
Java SWT SWTChart坐标图
2010-12-13 14:02 4525关键字: SWTChart 坐标图 链接:http://w ... -
java.lang.NoClassDefFoundError: com/ibm/icu/text/BreakIterator
2010-11-25 14:00 3150关键字:java.lang.NoClassDefFoundE ... -
类似百度和谷歌那样的自动提示组合框
2010-09-30 14:04 1345问题:http://www.iteye.com/problem ... -
一个日历程序 可农历到公历 公历到农历 第几周 显示节气
2010-07-02 20:01 2586public class Sample3 { privat ... -
一个简单的时钟程序
2010-07-02 19:24 1092public class Sample2 { privat ... -
Image中的transformation理解【swt.snippet】
2010-07-02 17:48 1505/****************************** ... -
计分器
2010-07-02 17:28 1140代码: public class Sample1 { p ... -
SWT资料
2010-06-30 19:24 832SWT-jface一些例子: http://www.j ... -
事件管理器 4个象限【还没有完成】
2010-06-23 17:12 11231,改完成了一个大概的样子,还要把Text改成List,可以添 ... -
利用SWT内部的图标
2010-06-23 16:55 2913import org.eclipse.swt.SWT; im ... -
SWT 浏览器
2010-06-23 16:48 2764这个来自书上的一个例子: package firstSWT ...
相关推荐
SWT表格管理类,包括表头排序事件,table宽度自适应事件,隔行颜色事件
一个SWT日期时间选择控件类,可方便地加入到自己的代码中,支持拖放
java swt自定义控件java swt自定义控件java swt自定义控件java swt自定义控件
SWT自带的DateTime控件属实不好用,而且无法绑定到其他控件上。因此自己写一个日历控件用着方便,功能大致如下: 1、日历控件可自定义设置常见的几种日期格式; 2、可以绑定注册到其他控件如:文本框、按钮、标签上...
swt自定义封装的日期时间选择控件,支持选择日期和时间
SWT表格管理类(包括表头排序,隔行颜色,表格宽度自适应)
SWT/JFACE的控件库毕竟有限,在应用开发是我们不可避免地要自己开发一些自定义的控件
Java使用SWT JFreeChart控件实现的小游戏.zipJava使用SWT JFreeChart控件实现的小游戏.zipJava使用SWT JFreeChart控件实现的小游戏.zipJava使用SWT JFreeChart控件实现的小游戏.zipJava使用SWT JFreeChart控件实现的...
SWT、JFACE控件实例,官方的东西,各种控件例子! 已经把包名等修复好了。直接导入IDE中可以运行。各种效果。
只要swt一个jar包即可,无需jacob,jna,jni等等,方法很简单
NULL 博文链接:https://lifei114.iteye.com/blog/827368
SWT Table 单元格编辑实例代码
SWT 第三方 date picker RCP
java浏览器控件 swt.jar 下载
NULL 博文链接:https://542255641.iteye.com/blog/2376642
此例子完整的包含了swt 所需的jar文件及执行jar文件的bat文件。展示了swt 时间选择控件及其他控件的用法,以及TimerTask的用法。
对于swt控件知识的部分整理,有助于对其的学习。
该文档包含swt所有控件的使用代码。大家可以不必为不知道某个控件怎么使用而犯愁。
SWT的自动化测试框架