用swt写的弹出式对话框
来源:互联网 发布:房间格局设计软件 编辑:程序博客网 时间:2024/05/16 03:46
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class Popup extends Thread {
Shell shell;
protected int moveStep = 2; //每次移动的pixel
protected int upPosition; //能移动到的最上面坐标
protected int downPosition; //当前popup的边框坐标
protected int leftPosition; //popup左边边框坐标
public Popup(final String message) {
shell = new Shell(SWT.ON_TOP);
Text text = new Text(shell, SWT.MULTI | SWT.WRAP);
text.setBounds(10, 20, 180, 80);
text.setBackground(shell.getBackground());
text.setText(message);
//取屏莫大小
Rectangle area = Display.getDefault().getClientArea();
upPosition = area.height - 100;//计算出popup界面在屏幕显示的最高位置
downPosition = area.height + 100;//计算出popup界面的初始位置
leftPosition = area.width - 180;
shell.setSize(180, 100);
//初始化popup位置
shell.setLocation(leftPosition, downPosition);
shell.open();
}
public void run() {
Display display = shell.getDisplay();
while (true) {
try {
Thread.sleep(10);
//判断当前位置是否小于能出现的最高位置,小于的话就说明还可以向上移动。
if ((downPosition - moveStep) > upPosition) {
display.asyncExec(new Runnable() {
public void run() {
shell.setLocation(leftPosition, downPosition- moveStep);
downPosition -= moveStep;
}
});
//此时已经移动到了最高位置,显示5秒钟后,关闭窗口并退出。
} else {
Thread.sleep(2000);
display.asyncExec(new Runnable() {
public void run() {
shell.dispose();
}
});
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
- 用swt写的弹出式对话框
- Swt弹出式对话框
- 用JavaScript写的一个自定义弹出式对话框
- SWT/JFace的对话框
- SWT的MessageBox对话框
- SWT的对话框们
- 一个创建弹出式对话框的函数
- VC弹出式对话框的程序实例
- 关于弹出式(POPUP)对话框的显示
- Android之AlertDialog(弹出式对话框)的使用
- java常用弹出式对话框
- alertdialog弹出式对话框
- Android 向下弹出式对话框
- AlertDialog_弹出式对话框
- 浏览器弹出式对话框
- Android使用弹出式对话框
- 非弹出式的模态对话框的背景遮罩
- 根据弹出式对话框的不同回答来处理
- Windows下JSP开发环境的配置
- Struts学习傻瓜式入门篇
- SQL Server 2005新功能 - TSQL
- JSP连接SQL Server 2000系统配置
- 框架实例
- 用swt写的弹出式对话框
- datalist嵌套datalist的实例
- win2000server IIS和tomcat5多站点配置
- menu4做的菜单在IE7下的变形问题
- Visual style theme
- New features in C# 2.0
- 从Table 表中取出第 m 条到第 n 条的记录:(Not In 版本)
- 常用日期解决方案
- 远程抓取页面信息并解析XML