消息提示客户端实现 要求:一个消息提示的客户端,通过轮询调用webservice调用服务器端的数据;给出提示,类似OA办公中的消息提示,可以直接点击连接到web页面;现在实现了一个比较简单的,总是不理想;有没有比较熟悉的,给个例子!谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 感谢大家的回答;我做了一些小例子;比如: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那样的,做的很实用; 使用swing类可不可以一次性向容器添加多个组件 数据库连接成功,但查询时出现对象名无效 java解析图片 printstream问题 关于包的问题. 请大家帮我解决一下这个问题吧,刚学Java,弄得不是很清楚 求一个正则表达式的写法 appletviewer 正确显示,可是用IE浏览只显示灰色一块,不显示字呢? 最初级的问题 请教~~ 简单的程序,简单的问题!! 求素数,求完美! 为什么总是显示java.lang.NullPointerException
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那样的,做的很实用;