import com.gc.systray.*;
import java.awt.Point;
import java.awt.event.*;
import javax.swing.*;
/**
* Test class
*/
public class RealTest implements SystemTrayIconListener {
/**
* SystemTrayIconListener implementation
*/
public void mouseClickedLeftButton(Point pos, SystemTrayIconManager source) {
System.out.println("left click at (" + pos.getX() + ", " + pos.getY() + ")");
}
public void mouseClickedRightButton(Point pos, SystemTrayIconManager ssource) {
System.out.println("right click at (" + pos.getX() + ", " + pos.getY() + ")");
}
public void mouseLeftDoubleClicked(Point pos, SystemTrayIconManager source) {
System.out.println("left double click at (" + pos.getX() + ", " + pos.getY() + ")");
}
public void mouseRightDoubleClicked(Point pos, SystemTrayIconManager source) {
System.out.println("right double click at (" + pos.getX() + ", " + pos.getY() + ")");
}
/**
* main method
*/
public static void main(String[] s) {
javax.swing.JPopupMenu jPopupMenu1 = new javax.swing.JPopupMenu();
javax.swing.JMenuItem jMenuItem1 = new javax.swing.JMenuItem();
javax.swing.JMenuItem jMenuItem2 = new javax.swing.JMenuItem();
javax.swing.JMenuItem jMenuItem3 = new javax.swing.JMenuItem();
jMenuItem2.setText("显示主窗体");
jPopupMenu1.add(jMenuItem2);
jMenuItem3.setText("属性");
jPopupMenu1.add(jMenuItem3);
jMenuItem1.setText("退出");
jPopupMenu1.add(jMenuItem1);
if (!SystemTrayIconManager.initializeSystemDependent()) {
System.out.println("DLL error");
return;
}
int quick = SystemTrayIconManager.loadImage("icon.ico");
if (quick == -1) {
System.out.println("image icon.ico error");
return;
}
RealTest rt = new RealTest();
final SystemTrayIconManager mgr = new SystemTrayIconManager(quick, "Test tooltip");
mgr.addSystemTrayIconListener(rt);
jMenuItem1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Event: " + e.getSource());
mgr.setVisible(false);
System.exit(0);
}
});
mgr.setRightClickView(jPopupMenu1);
//mgr.setLeftClickView(new javax.swing.JLabel("Text test"));
mgr.setLeftClickView(new JFrame("Frame Title"));
mgr.setVisible(true);
try {
while (true) {
synchronized( rt ) {
rt.wait(1);
}
}
}
catch( InterruptedException x ) {}
mgr.setVisible(false);
mgr.removeSystemTrayIconListener(rt);
System.err.println("Bye bye!");
System.exit(0);
}
}
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
ecstar
- 粉丝: 1
- 资源: 4
最新资源
- 管理 Python 包的命令行工具
- SWAT模型-全国河流水文站坐标
- vmware 虚拟机 version=17
- python 2.7 for systrace
- SWAT模型-SPAW土壤数据库辅助工具
- Java程序设计实验报告 异常的使用
- 操作系统课程设计 进程调度系统设计 采用FCFS、SPF或优先级调度算法 C++、Java
- The Bluetooth Low Energy Primer v1.2.0 updated 202403
- gcc-linaro-7.3.1-2018.05-x86-64-aarch64-linux-gnu.tar
- 基于Java的客户管理系统源码,CRM 带小程序 CRM小程序源码 1. 前端:Vue 2. 后端:Spring boot
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)