java实现像QQ新闻消息提示对话框

 我们都知道QQ如果有什么重大新闻时会第一时间在右下角弹出一个消息提示框的.而且会有一些动画.实现这个其实并不难,很简单,关键在于它的一些外观,以及鼠标移动等操作.

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.lgh.mail.components;

import com.lgh.pic.Pic;
import com.lgh.util.MouseMotionUtil;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JPanel;
import javax.swing.JWindow;

/**
 *
 * @author lgh
 */
public class TipWindow extends JWindow implements Runnable {

    private static Dimension dim;
    private int x,  y;
    private int width,  height;


    {
        dim = Toolkit.getDefaultToolkit().getScreenSize();
        width = 200;
        height = 150;
        x = (int) (dim.getWidth() - width);
        y = (int) (dim.getHeight());
    }

    public TipWindow() {
        initComponents();
        new Thread(this).start();
    }

    public void run() {
        for (int i = 0; i <= height; i += 10) {
            try {
                this.setLocation(x, y - i);
                Thread.sleep(20);
            } catch (InterruptedException ex) {
                Logger.getLogger(TipWindow.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    private void initComponents() {
        this.setSize(width, height);
        this.setLocation(x, y);
        this.setLayout(new BorderLayout());
        JPanel tipBar = createTipBar();
        new MouseMotionUtil().addMouseMotionListener(this, tipBar);
        this.add(tipBar, BorderLayout.NORTH);
        this.setVisible(true);

    }

    /**
     * 创建上面的工具条
     */
    private JPanel createTipBar() {
        TipBar tipBar = new TipBar(Pic.TOP_BAR_BG_MID);
        return tipBar;
    }

    private class TipBar extends MailPanel implements ActionListener {

        private MailButton closeButton;

        public TipBar(Image bgImage) {
            super(bgImage);
            initComponents();
        }

        private void initComponents() {
            closeButton = new MailButton(Pic.map.get("mail/buttons/button_close"), new Rectangle(170, 1, 26, 26));
            this.setLayout(null);
            closeButton.addListenAndCommand(this, "closeButton");
            this.add(closeButton);
            this.setPreferredSize(new Dimension(width, 26));
        }

        public void actionPerformed(ActionEvent e) {
            String command = e.getActionCommand();
            if (command != null) {
                if (command.equals("closeButton")) {
                    TipWindow.this.dispose();
                }
            }
        }
    }

    public static void main(String[] args) {
        new TipWindow();
    }
}

  

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
EQ使用说明书 系统介绍 本系统主要由通讯列表维护、系统操作、系统设置、任务栏操作、系统公告管理和系统升级6部分组成: q 通讯列表维护 通讯列表维护包括用户更名、添加用户、删除用户和显示列表。 q 系统操作 系统操作包括选择界面外观、搜索用户、系统更新。 q 系统设置 系统设置包括系统路径设置、登录信息设置、IP搜索范围设置。 q 任务栏操作 任务栏操作包括打开窗体、访问服务器、退出。 q 公告管理 公告管理用于向所有用户显示企业公告。 q 系统升级 系统升级可以维护系统的最新版本。 操作流程 使用本程序时,请按以下步骤操作: (1)单击“系统设置”选项卡,设置系统、IP搜索范围和服务器登录设置。如图1.1所示。 图1.1 系统设置 图1.2 用户搜索 (2)单击“系统操作”选项卡,搜索新的用户,如图1.2所示,如果你知道对方的IP地址,单击“用户列表”选项卡,选中其中的一个用户单击鼠标右键弹出快捷菜单,如图1.3所示。在该菜单中,可对用户信息进行添加、删除、用户更名、访问主机资源及公共程序等操作。 图1.3 系统操作 图1.4 使用信使发布消息 (3)如果对方未开启企业通信系统的情况下,向对方发送信史信息,如图1.4所示。 (4)本程序还支持群发功能,按住键盘上的键,选择需要发送信息的人,然后,单击鼠标右键选择“信使群发”命令,进行信使群发操作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值