要求:一个消息提示的客户端,通过轮询调用webservice调用服务器端的数据;给出提示,类似OA办公中的消息提示,可以直接点击连接到web页面;现在实现了一个比较简单的,总是不理想;有没有比较熟悉的,给个例子!
谢谢!

解决方案 »

  1.   

    感谢大家的回答;我做了一些小例子;比如:public class TestMsg extends TimerTask{ public void run() {
    test();
    }

    private void test(){

        JFrame parent = new JFrame();
        try{
              String res = "test...";
    JOptionPane.showMessageDialog(parent, res);
    }catch(Exception e){
    e.printStackTrace();
    } }}//通过调用代码
    Timer upTimer = new Timer();
    upTimer.schedule(new TestMsg(), 3000, 3000);这个就是能够定时弹出消息;当然通过判断是否有消息弹出;没有则不弹出,但是中间消息这块;我想换为一个链接页面,能快速进入到相关页面;
    public class SystemTrayDemo extends JFrame{
        private TrayIcon trayIcon = null;   
        public SystemTrayDemo(){
            this.setTitle("消息提示");
            jbInit();
            this.setSize(250, 180);
            this.setLocation(600, 500);
        }
        public void jbInit(){
            if(SystemTray.isSupported()){ //检查当前系统是否支持系统托盘
                 SystemTray tray = SystemTray.getSystemTray();//获取表示桌面托盘区的 SystemTray 实例。
                 Image image  = Toolkit.getDefaultToolkit().getImage("D:\\pic.gif");
                 PopupMenu popupMenu = new PopupMenu(); 
                 MenuItem  exitItem  = new MenuItem("关闭"); 
                 MenuItem  menuItema  = new MenuItem("menu a"); 
                 MenuItem  menuItemb = new MenuItem("menu b"); 
                 exitItem.addActionListener(new  ActionListener(){
                     public void actionPerformed(ActionEvent e)     {   
                         try{     
                              System.exit(0);     
                           }catch(Exception   ex)   {   
                               ex.printStackTrace();   
                           }   
                     }
                 });      
                 popupMenu.add(menuItema); 
                 popupMenu.add(menuItemb); 
                 popupMenu.add(exitItem);  
                 trayIcon = new TrayIcon(image, "系统托盘{pic}",  popupMenu);   
                 trayIcon.addMouseListener(new java.awt.event.MouseAdapter(){
                    @Override
                    public void mouseClicked(MouseEvent e) {
                       if(e.getClickCount()==2){   
                           showIT(true);   
                        }
                    }     
                 });
                 try{   
                      tray.add(trayIcon);  // 将 TrayIcon 添加到 SystemTray。 
                 } catch   (AWTException   e)     {   
                      System.err.println(e);   
                 }
            }else{
                System.out.println("你的系统不支持系统托盘");
            }
            /*ImageIcon icon = new ImageIcon();
            try{
                URL url = new URL("http://www.baidu.com");
                icon = new ImageIcon(url);
            }catch(Exception e){
                
            }    
            JLabel label = new JLabel();
            label.setIcon(icon);
            this.add(label);*/
            JLabel label = new JLabel();
            label.setText("测试程序");
            this.add(label);
        }
        public void showIT(boolean visable){
            if(this.isVisible() != visable)
                this.setVisible(visable);
        }
        
        public static void main(String[] args) {
            javax.swing.SwingUtilities.invokeLater(new Runnable(){
                public void run(){
                    new SystemTrayDemo().setVisible(true);
                }
            });
        }
    }
    上面作为了一个托盘;现在怎么能够组合起来,类似QQ那样的,做的很实用;