- 浏览: 185101 次
- 性别:
- 来自: 长沙
文章分类
最新评论
-
LXX516:
LXX516 写道你好,运行时出现如下问题:E/Trace(1 ...
PC客户端与Android实现图片传送 -
LXX516:
你好,运行时出现如下问题:E/Trace(15019): er ...
PC客户端与Android实现图片传送 -
huzhenyu:
希望各位大顶起,支持国产免费软件
公式编辑器MathMarkEdit1.0发布 -
zhangyou1010:
默认是8000的端口,如果用sh catalina.sh jp ...
使用eclipse远程调试部署在tomcat上的应用程序 -
zhangyou1010:
有时间,也要玩玩QT,哈哈。
Qt Grid布局
/*******************************************************************************
* 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;
/*
* Composite example snippet: scroll a child control automatically
*
* 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.FillLayout;
import org.eclipse.swt.widgets.*;
public class Snippet9 {
public static void main (String [] args) {
Display display = new Display ();
final Shell shell = new Shell (display, SWT.SHELL_TRIM | SWT.H_SCROLL | SWT.V_SCROLL);
final Composite composite = new Composite (shell, SWT.BORDER);
composite.setEnabled (false);
composite.setLayout (new FillLayout ());
composite.setSize (700, 600);
final Color red = display.getSystemColor (SWT.COLOR_RED);
composite.addPaintListener (new PaintListener() {
public void paintControl (PaintEvent e) {
e.gc.setBackground (red);
e.gc.fillOval (5, 5, 690, 590);
}
});
final ScrollBar hBar = shell.getHorizontalBar ();
hBar.addListener (SWT.Selection, new Listener () {
public void handleEvent (Event e) {
Point location = composite.getLocation ();
location.x = -hBar.getSelection ();
composite.setLocation (location);
}
});
final ScrollBar vBar = shell.getVerticalBar ();
vBar.addListener (SWT.Selection, new Listener () {
public void handleEvent (Event e) {
Point location = composite.getLocation ();
location.y = -vBar.getSelection ();
composite.setLocation (location);
}
});
shell.addListener (SWT.Resize, new Listener () {
public void handleEvent (Event e) {
Point size = composite.getSize ();
Rectangle rect = shell.getClientArea ();
hBar.setMaximum (size.x);
vBar.setMaximum (size.y);
hBar.setThumb (Math.min (size.x, rect.width));
vBar.setThumb (Math.min (size.y, rect.height));
int hPage = size.x - rect.width;
int vPage = size.y - rect.height;
int hSelection = hBar.getSelection ();
int vSelection = vBar.getSelection ();
Point location = composite.getLocation ();
if (hSelection >= hPage) {
if (hPage <= 0) hSelection = 0;
location.x = -hSelection;
}
if (vSelection >= vPage) {
if (vPage <= 0) vSelection = 0;
location.y = -vSelection;
}
composite.setLocation (location);
}
});
final Point [] offset = new Point [1];
Listener listener = new Listener () {
public void handleEvent (Event event) {
switch (event.type) {
case SWT.MouseDown:
Rectangle rect = composite.getBounds ();
if (rect.contains (event.x, event.y)) {
Point pt1 = composite.toDisplay (0, 0);
Point pt2 = shell.toDisplay (event.x, event.y);
offset [0] = new Point (pt2.x - pt1.x, pt2.y - pt1.y);
}
break;
case SWT.MouseMove:
if (offset [0] != null) {
Point pt = offset [0];
composite.setLocation (event.x - pt.x, event.y - pt.y);
System.out.println("x : " + event.x + " y : " + event.y);
hBar.setSelection(pt.x - event.x);
vBar.setSelection(pt.y - event.y);
}
break;
case SWT.MouseUp:
offset [0] = null;
break;
}
}
};
shell.addListener (SWT.MouseDown, listener);
shell.addListener (SWT.MouseUp, listener);
shell.addListener (SWT.MouseMove, listener);
shell.setSize(600, 500);
shell.open ();
while (!shell.isDisposed()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
* 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;
/*
* Composite example snippet: scroll a child control automatically
*
* 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.FillLayout;
import org.eclipse.swt.widgets.*;
public class Snippet9 {
public static void main (String [] args) {
Display display = new Display ();
final Shell shell = new Shell (display, SWT.SHELL_TRIM | SWT.H_SCROLL | SWT.V_SCROLL);
final Composite composite = new Composite (shell, SWT.BORDER);
composite.setEnabled (false);
composite.setLayout (new FillLayout ());
composite.setSize (700, 600);
final Color red = display.getSystemColor (SWT.COLOR_RED);
composite.addPaintListener (new PaintListener() {
public void paintControl (PaintEvent e) {
e.gc.setBackground (red);
e.gc.fillOval (5, 5, 690, 590);
}
});
final ScrollBar hBar = shell.getHorizontalBar ();
hBar.addListener (SWT.Selection, new Listener () {
public void handleEvent (Event e) {
Point location = composite.getLocation ();
location.x = -hBar.getSelection ();
composite.setLocation (location);
}
});
final ScrollBar vBar = shell.getVerticalBar ();
vBar.addListener (SWT.Selection, new Listener () {
public void handleEvent (Event e) {
Point location = composite.getLocation ();
location.y = -vBar.getSelection ();
composite.setLocation (location);
}
});
shell.addListener (SWT.Resize, new Listener () {
public void handleEvent (Event e) {
Point size = composite.getSize ();
Rectangle rect = shell.getClientArea ();
hBar.setMaximum (size.x);
vBar.setMaximum (size.y);
hBar.setThumb (Math.min (size.x, rect.width));
vBar.setThumb (Math.min (size.y, rect.height));
int hPage = size.x - rect.width;
int vPage = size.y - rect.height;
int hSelection = hBar.getSelection ();
int vSelection = vBar.getSelection ();
Point location = composite.getLocation ();
if (hSelection >= hPage) {
if (hPage <= 0) hSelection = 0;
location.x = -hSelection;
}
if (vSelection >= vPage) {
if (vPage <= 0) vSelection = 0;
location.y = -vSelection;
}
composite.setLocation (location);
}
});
final Point [] offset = new Point [1];
Listener listener = new Listener () {
public void handleEvent (Event event) {
switch (event.type) {
case SWT.MouseDown:
Rectangle rect = composite.getBounds ();
if (rect.contains (event.x, event.y)) {
Point pt1 = composite.toDisplay (0, 0);
Point pt2 = shell.toDisplay (event.x, event.y);
offset [0] = new Point (pt2.x - pt1.x, pt2.y - pt1.y);
}
break;
case SWT.MouseMove:
if (offset [0] != null) {
Point pt = offset [0];
composite.setLocation (event.x - pt.x, event.y - pt.y);
System.out.println("x : " + event.x + " y : " + event.y);
hBar.setSelection(pt.x - event.x);
vBar.setSelection(pt.y - event.y);
}
break;
case SWT.MouseUp:
offset [0] = null;
break;
}
}
};
shell.addListener (SWT.MouseDown, listener);
shell.addListener (SWT.MouseUp, listener);
shell.addListener (SWT.MouseMove, listener);
shell.setSize(600, 500);
shell.open ();
while (!shell.isDisposed()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
发表评论
-
解决Android Manager不能更新问题
2012-10-14 15:56 996估计这又是伟大GFW的功劳,我们只需要配置一下hosts文件, ... -
Eclipse中Action创建的两种方式
2011-04-25 11:03 6808在Eclipse里,是由actions来描述菜单及工具栏的可以 ... -
改变swt中table选中行的颜色
2011-03-07 16:17 6276import org.eclipse.swt.*; impo ... -
menu显示在特定视图中
2010-08-17 10:41 916<visibleWhen checkEnabled=&q ... -
rcp中获取bundle中资源文件的两种方法
2010-07-15 12:53 1825Bundle bundle = Platform.getBun ... -
去掉eclipse上的菜单
2010-07-12 13:08 1112WorkbenchWindow window = (Workb ... -
eclipse rcp显示/隐藏视图
2010-07-08 16:45 2213/** * 显示视图 * @param id 视图ID ... -
RCP 视图最大化
2010-07-08 16:42 1514findLeftViewStack(CurrentDealVi ... -
Riena
2010-07-07 23:41 1028Riena平台将是建立多层C/S企业应用的基础。通过提供一种透 ... -
rcp text combo 仿google检索效果
2010-06-24 13:02 1013http://ncu.dl.sourceforge.net/p ... -
eclipse rcp popup menu
2010-06-17 23:02 2245在做RCP开发中遇到个问题,搞了大半天。代码贴出来: view ... -
分享两个不错的基于RCP的开源项目
2010-06-08 16:29 1843http://sourceforge.net/projects ... -
eclipse jdt初探
2010-06-03 23:30 1266最近打算了解下jdt,以便以后做些代码辅助工具 下面记一些代码 ... -
RCP中实现截屏
2010-06-02 22:53 920http://www.java2s.com/Tutorial/ ... -
怎样基于eclipse做一个进度条
2010-06-01 22:37 2597代码: package rcpmail; import ... -
eclipse3.2版以外3.3,3.4,3.5汉化安装
2010-05-31 20:09 1587很多喜欢eclipse的朋友,比较关心eclipse是不是能汉 ... -
eclipse插件及rcp国际化实现
2010-05-22 11:50 1312方式一: package test; import ja ... -
eclipse实用插件集
2010-05-22 11:21 1697FengShen_Xia 2009-03-05 1 ... -
OSGI 伙伴类加载器
2010-05-16 11:59 1076伙伴类加载器选项 首先为 Hibernate 创建插件。然后 ... -
实用eclipse插件工具
2010-04-16 22:41 822http://subclipse.tigris.org/ SV ...
相关推荐
Jfreechart提供的SWT接口,并不支持滚动条,本资源实现了这个方法
swt table 实现换行
SWT原生按钮不够美观,本案例实现自定义圆形按钮,代码可直接下载使用。
手写基于Swt/Jface图片工厂实现图片传输界面更新。应用于项目中的工具类,供大家学习参考。提供一种新的学习思路。
ScrolledComposite自动出现最适合大小的滚动条代码
swt创建tree的例子 swt创建tree的例子 swt创建tree的例子
SWT实现图片列表预览, 封装了一个用于展示图片的类,根据构造方法可以设置显示的行数及列数。根据设置的宽高进行自适应,可以实现滚动条,选择,查看,全选,反选,图片大小自适应等其他操作。
在swt开发中实现的一个小小的日历对话框,与文本框共同使用的,可以供大家参考,
SWT插件中文教程SWT常用方法SWT插件中文教程SWT常用方法SWT插件中文教程SWT常用方法SWT插件中文教程SWT常用方法SWT插件中文教程SWT常用方法SWT插件中文教程SWT常用方法
Eclipse中使用SWT进行界面设计 1. 为什么要使用SWT? 2. SWT应用程序的组成 3. 进行SWT开发前的环境设置
java SWT 基本窗口 组件 开发
SWT中文教程.rar/////SWT中文教程.rar
SWT无边框窗体实现鼠标拖动移动,并添加右键菜单关闭功能
java swt版本的qq可以实现的功能
SWT Table 单元格编辑实例代码
SWT最大化了操作系统的图形构件API,就是说只要操作系统提供了相应图形的构 件,那么SWT只是简单应用JNI技术调用它们,只有那些操作系统中不提供的构件,SWT才自己去做一个模拟的实现。可以看出SWT的性能上的稳定...
SWT中实现shell Canvas Composite等控件的背景透明
SWT配置 SWT配置 SWT配置 SWT配置 SWT配置 SWT配置 SWT配置 SWT配置
利用SWT算法实现,c++编写,可用于图像文字提取
java用SWT制作界面的简易计算器,可实现加减乘除和小数的运算