如何在java中的系统托盘中显示气球提示文本

时间:2014-03-14 06:42:01

标签: java timer intervals balloon-tip

Hie Friends。

我正在开发一个JAVA应用程序,它要求Balloon-Tip Text应该以1小时的固定间隔显示。

我正在努力尝试,但不知道如何使用气球文字请任何人帮助我。

提前致谢。

我的代码是:

public void timer_clock()
{   
    theChronometer = new Timer(1000,new ActionListener()
    {
        int seconds,days,hours,min,sec;
        public void actionPerformed(ActionEvent e)
        {
            seconds = (int)(System.currentTimeMillis()-watchStart)/1000;

            days = seconds / 86400;
    hours = (seconds / 3600) - (days * 24);
    min = (seconds / 60) - (days * 1440) - (hours * 60);
    sec = seconds % 60;

            String s=new String("" + String.format("%02d", hours) + ":"+ String.format("%02d", min) + ":"+ String.format("%02d", sec));

        label.setText(s);

            label.setFont(new java.awt.Font("Times New Roman", 0, 34));

            switch(s)
            {
                case "00:00:01":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);

                    break;
                case "01:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;
                case "02:00:00":
                   trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                   break;
                case "03:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;
                case "04:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;
                case "05:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;    
                case "06:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;
                case "07:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;
                case "08:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;
                case "09:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;
                case "10:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;
                case "11:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;    
                case "12:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;    
                 case "13:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;
                case "14:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;
                case "15:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;
                case "16:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;
                case "17:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;    
                case "18:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;    
                 case "19:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;
                case "20:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;
                case "21:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;
                case "22:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;
                case "23:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;    
                case "24:00:00":
                    trayIcon.displayMessage("Soul Spotter", "\nYour Total WorkTime Is: \n\n"+s , TrayIcon.MessageType.INFO);
                    break;    
            }
        }

        private int length(String toString) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    });
    timer_started();
}
public void timer_started()
{
    watchStart = System.currentTimeMillis();
    theChronometer.start();
}

请告诉我在开关案例中写些什么。 (我已经通过上面编辑的代码解决了这个问题) 感谢

0 个答案:

没有答案