/** * 查询信息 */ public void checkMessage(){ TimerTask tt = new TimerTask() { public void run() { String unreadMsgNo = new CheckMessage().getUnreadMsgNo (URL, USER, PASSWORD); if(unreadMsgNo.equals("0")){ jLabelMsgTip.setText("您没有新信息!"); } else{ jLabelMsgTip.setText("您有" + unreadMsgNo + "条新信息!"); } } }; Timer t = new Timer(); t.schedule(tt, 0, (long)1000*15);//每隔15秒执行一次 }
每隔一定时间间隔查询是否有新消息
Published in CrazyBus
Comments