Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > Java > 类似qq上线提示的一个java程序
【标  题】:类似qq上线提示的一个java程序
【关键字】:qq,java
【来  源】:http://blog.csdn.net/huxb23/archive/2006/09/11/1208899.aspx

类似qq上线提示的一个java程序

Your Ad Here

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
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;
 protected int upPosition;
 protected int downPosition;
 protected int leftPosition;

 public Popup(final String message) {

  shell = new Shell(SWT.ON_TOP);
 
  shell.setBackground(new Color(Display.getCurrent(), 23, 184, 237));
  Text text = new Text(shell, SWT.MULTI | SWT.WRAP);
  text.setBounds(10, 20, 180, 80);
  text.setBackground(shell.getBackground()); 
  text.setForeground(new Color(Display.getCurrent(), 221, 55, 84));
  text.setText(message);
  Rectangle area = Display.getDefault().getClientArea();

  upPosition = area.height - 100;
  downPosition = area.height + 100;
  leftPosition = area.width - 180;

  shell.setSize(180, 100);
  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;
      }
     });
    } else {
     Thread.sleep(6000);
     display.asyncExec(new Runnable() {
      public void run() {
       shell.dispose();
      }
     });
    }
   } catch (InterruptedException e) {
   e.printStackTrace();
   }
  }
 }

所谓性能、所谓优化:【上一篇】
读文件:【下一篇】
【相关文章】
  • java游戏——倒鸡毛Beta1.0.1
  • 刚抄袭他人的,JAVA新特性。哎.......
  • Java虚拟机的深入研究 zz
  • 对java.util的总结 一
  • [转] 谈谈 JAVA 程序的反编译
  • 由生产者/消费者问题看JAVA多线程
  • Javasssist初探(需要对Java的ClassLoader机制有一些了解)
  • java.exe -X 参数信息
  • 利用java的反射机制得到类的信息
  • Jsp中配置JavaBean
  • 【随机文章】
  • 光网络基础结构的延伸
  • Web网站的错误控制(转)
  • 让我激动的CSS+DIV开发利器--GoLive
  • 方法AsyncOperation.Post()的不确定性
  • 选择java的理由:java之父访谈实录
  • 秘籍!面部皮肤过敏的影响将不再,美丽更胜以往
  • 应用程序如何使用驱动程序
  • 从资源中加载皮肤, 使用免费界面库 AppFace For VC 0.2 美化您的软件
  • 关于jspsmartupload的上传
  • 在A*寻路算法中使用二元堆(上)
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.