資源簡介
1、使用java的Jframe開發(fā)!未引用任何第三方插件!自動隱藏任務(wù)欄顯示!可最小化為系統(tǒng)托盤!右鍵菜單可徹底退出釋放!窗口始終置頂!窗口可拖拽!2、請不要破壞文件結(jié)構(gòu)!重要!解壓后雙擊Listener.exe即可運行程序,該程序依賴同文件夾下的【jre】(java環(huán)境,可替換為你的jre文件夾,版本號1.6-1.9,默認(rèn)1.8)和【image】文件夾(存放背景圖片)。3、項目源碼直接導(dǎo)入eclipse即可修改編輯。4、所有代碼就一個類(249行代碼未引用任何第三方j(luò)ar包)。5、備注:使用exe4j生成的exe文件,jre請自行壓縮瘦身,左邊球為內(nèi)存,右邊為cpu。
代碼片段和文件信息
package?com;
import?java.awt.AWTException;
import?java.awt.Color;
import?java.awt.Dimension;
import?java.awt.Font;
import?java.awt.MenuItem;
import?java.awt.Point;
import?java.awt.PopupMenu;
import?java.awt.SystemTray;
import?java.awt.Toolkit;
import?java.awt.TrayIcon;
import?java.awt.event.ActionEvent;
import?java.awt.event.ActionListener;
import?java.awt.event.MouseAdapter;
import?java.awt.event.MouseEvent;
import?java.awt.event.MouseListener;
import?java.awt.event.MouseMotionListener;
import?java.lang.management.ManagementFactory;
import?javax.swing.ButtonGroup;
import?javax.swing.ImageIcon;
import?javax.swing.Jframe;
import?javax.swing.JLabel;
import?javax.swing.JlayeredPane;
import?javax.swing.JPanel;
import?javax.swing.JPopupMenu;
import?javax.swing.JRadioButtonMenuItem;
import?com.sun.management.OperatingSystemMXBean;
public?class?Mylistener?extends?Jframe?implements?MouseListener
MouseMotionListener?{
/**
?*?
?*/
private?static?final?long?serialVersionUID?=?1L;
private?static?Mylistener?frame;
private?static?OperatingSystemMXBean?osmxb?=?(OperatingSystemMXBean)?ManagementFactory
.getOperatingSystemMXBean();
private?static?JRadioButtonMenuItem?items[];?//?菜單項
private?static?JPopupMenu?popupMenu;?//?彈出菜單
private?static?JLabel?text;//?文字,記錄cpu、內(nèi)存使用率。
static?SystemTray?tray?=?SystemTray.getSystemTray();//?系統(tǒng)托盤
private?static?TrayIcon?trayIcon?=?null;//?托盤圖標(biāo)
Boolean?tBoolean?=?false;
Point?fPoint;
Point?sPoint;
Point?tPoint;
//?構(gòu)造函數(shù)
public?Mylistener()?{
this.setUndecorated(true);//?禁用jframe自帶修飾
com.sun.awt.AWTUtilities.setWindowOpacity(this?1.0f);//?設(shè)置透明
addMouseListener(this);//?添加鼠標(biāo)監(jiān)聽
addMouseMotionListener(this);//?添加鼠標(biāo)監(jiān)聽
MouseAction?action?=?new?MouseAction();?//?菜單項事件處理
popupMenu?=?new?JPopupMenu();?//?實例化彈出菜單
ButtonGroup?colorGroup?=?new?ButtonGroup();?//?實例化按鈕組
items?=?new?JRadioButtonMenuItem[2];?//?初始化數(shù)組
items[0]?=?new?JRadioButtonMenuItem(“最小化“);?//?實例化最小化菜單項
popupMenu.add(items[0]);?//?增加菜單項到菜單上
colorGroup.add(items[0]);?//?增加菜單項到按鈕組
items[0].addActionListener(action);?//?菜單項事件處理
items[1]?=?new?JRadioButtonMenuItem(“徹底退出“);?//?實例化徹底退出菜單項
popupMenu.add(items[1]);?//?增加菜單項到菜單上
colorGroup.add(items[1]);?//?增加菜單項到按鈕組
items[1].addActionListener(action);?//?菜單項事件處理
}
public?static?void?main(String[]?args)?throws?Exception?{
//?創(chuàng)建一個JlayeredPane用于分層的。
JlayeredPane?layeredPane?=?new?JlayeredPane();
//?找一張圖作背景。
ImageIcon?image?=?new?ImageIcon(“image/backimg.png“);
//?創(chuàng)建背景。
JPanel?jpimage?=?new?JPanel();
//?設(shè)置背景透明。
jpimage.setBackground(null);
jpimage.setOpaque(false);
//?設(shè)置圖片位置。
jpimage.setBounds(0?0?image.getIconWidth()?60);
//?創(chuàng)建一個Label用于存放圖片。
JLabel?jlimage?=?new?JLabel(image);
//?jl.setBounds(00image.getIconWidth()image.getIconHeight());
jpimage.add(jlimage);
text?=?new?JLabel(“12%??15%“);
text.setSize(120?20);
text.setFont(new?Fo
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????3244??2017-09-05?20:17??all\jre\COPYRIGHT
?????文件?????????40??2017-09-05?20:17??all\jre\LICENSE
?????文件?????????46??2017-09-05?20:17??all\jre\README.txt
?????文件??????63933??2017-09-05?11:29??all\jre\THIRDPARTYLICENSEREADME-JAVAFX.txt
?????文件?????145180??2017-09-05?20:17??all\jre\THIRDPARTYLICENSEREADME.txt
?????文件????????955??2017-09-05?20:17??all\jre\Welcome.html
?????文件??????15392??2017-09-05?20:49??all\jre\bin\JAWTAccessBridge-64.dll
?????文件?????142368??2017-09-05?20:49??all\jre\bin\JavaAccessBridge-64.dll
?????文件?????110112??2017-09-05?20:52??all\jre\bin\WindowsAccessBridge-64.dll
?????文件??????19264??2017-09-05?11:29??all\jre\bin\api-ms-win-core-console-l1-1-0.dll
?????文件??????18752??2017-09-05?11:29??all\jre\bin\api-ms-win-core-datetime-l1-1-0.dll
?????文件??????18752??2017-09-05?11:29??all\jre\bin\api-ms-win-core-debug-l1-1-0.dll
?????文件??????18752??2017-09-05?11:29??all\jre\bin\api-ms-win-core-errorhandling-l1-1-0.dll
?????文件??????22336??2017-09-05?11:29??all\jre\bin\api-ms-win-core-file-l1-1-0.dll
?????文件??????18752??2017-09-05?11:29??all\jre\bin\api-ms-win-core-file-l1-2-0.dll
?????文件??????18744??2017-09-05?11:29??all\jre\bin\api-ms-win-core-file-l2-1-0.dll
?????文件??????18752??2017-09-05?11:29??all\jre\bin\api-ms-win-core-handle-l1-1-0.dll
?????文件??????19264??2017-09-05?11:29??all\jre\bin\api-ms-win-core-heap-l1-1-0.dll
?????文件??????18752??2017-09-05?11:29??all\jre\bin\api-ms-win-core-interlocked-l1-1-0.dll
?????文件??????19264??2017-09-05?11:29??all\jre\bin\api-ms-win-core-libraryloader-l1-1-0.dll
?????文件??????21312??2017-09-05?11:29??all\jre\bin\api-ms-win-core-localization-l1-2-0.dll
?????文件??????19264??2017-09-05?11:29??all\jre\bin\api-ms-win-core-memory-l1-1-0.dll
?????文件??????18752??2017-09-05?11:29??all\jre\bin\api-ms-win-core-namedpipe-l1-1-0.dll
?????文件??????19776??2017-09-05?11:29??all\jre\bin\api-ms-win-core-processenvironment-l1-1-0.dll
?????文件??????20800??2017-09-05?11:29??all\jre\bin\api-ms-win-core-processthreads-l1-1-0.dll
?????文件??????19256??2017-09-05?11:29??all\jre\bin\api-ms-win-core-processthreads-l1-1-1.dll
?????文件??????18240??2017-09-05?11:29??all\jre\bin\api-ms-win-core-profile-l1-1-0.dll
?????文件??????19264??2017-09-05?11:29??all\jre\bin\api-ms-win-core-rtlsupport-l1-1-0.dll
?????文件??????18752??2017-09-05?11:29??all\jre\bin\api-ms-win-core-string-l1-1-0.dll
?????文件??????20800??2017-09-05?11:29??all\jre\bin\api-ms-win-core-synch-l1-1-0.dll
............此處省略255個文件信息
- 上一篇:java模擬鍵盤輸入
- 下一篇:java開發(fā)單機冒險島
評論
共有 條評論