Java SE6 系统托盘小应用哈
/**
* @(#)MyTray.java
*
*
* @author Xie Xiaojin
* @version 1.00 2009/11/9
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class MyTray implements ActionListener {
private MenuItem item1;
private MenuItem item2;
private MenuItem item3;
private String tip = "谢小进于\n2009年11月9日\n凌晨2:52";
public MyTray(){
if(SystemTray.isSupported()){
SystemTray tray = SystemTray.getSystemTray();
PopupMenu popup = new PopupMenu();
item1 = new MenuItem("我的菜单");
item2 = new MenuItem("关于");
item3 = new MenuItem("退出");
item2.addActionListener(this);
item3.addActionListener(this);
popup.add(item1);
popup.add(item2);
popup.add(item3);
TrayIcon icon = new TrayIcon(getIcon("rss.png").getImage(), tip, popup);
icon.displayMessage("系统提示", tip, TrayIcon.MessageType.INFO);
try{
tray.add(icon);
} catch(AWTException ex){
System.err.println("无法向这个托盘添加新菜单项");
}
} else{
System.out.println("无法使用系统托盘");
}
}
public static void main(String[] args){
new MyTray();
}
public ImageIcon getIcon(String url){
return new ImageIcon(getClass().getResource(url));
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == item2){
JFrame f = new JFrame("系统托盘");
JLabel label = new JLabel(tip);
f.getContentPane().add(label);
f.setSize(300, 200);
f.setLocationRelativeTo(null);
f.setVisible(true);
}
if(e.getSource() == item3){
System.exit(0);
}
}
}
相关文档:
1. 对于一个static方法而言,无法访问泛型类的类型参数,所以,如果static方法需要使用泛型能力,就必须使其成为泛型方法。
2. 当使用泛型类时,必须在创建对象的时候制定类型参数的值,而是用泛型方法的时候,通常不必指定参数类型,因为编译器会为我们找出具体的类型。这称为类型参数推断。 ......
预备知识
本教程针对使用过 Rational ClearQuest Test Management 的人员。需要你了解 CQTM 中的基本概念。另外你最好了解 Eclipse,但不是必需的。
系统需求
您可以安装 IBM WebSphere Integration Developer 来运行本文中的示例程序。
Rational ClearQuest Test Manager(CQTM)简介
目 ......
int temp;
int [] arr=new int[];
for(int i=0;i<arr.length;i++)
{
for(int j=0;j<arr.length-i-1;j++)
{
if(arr[j]<arr[j+1])
{
& ......
环境JDK1.5
Eclipse 3.2
直接上代码:如果没有配置好环境请参看前两篇日志
服务器端代码
User类:
/*
*Class User.java
*Create Date: 2009-11-4
*Author:a276202460
*/
package com.axis.pojo.test;
public class User implements java.io.Serializable{
public boolean equals(Object obj) {
if (obj == ......
1.基本概念的理解
绝对路径:绝对路径就是你的主页上的文件或目录在硬盘上真正的路径,(URL和物理路径)例如:
C:xyz est.txt 代表了test.txt文件的绝对路径。http://www.sun.com/index.htm也代表了一个URL绝对路径。
相对路径:相对与某个基准目录的路径。包含Web的相对路径(HTML中的相对目录),例如:在
Ser ......