亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? testtrayicon.java

?? 用Java實(shí)現(xiàn)Windows系統(tǒng)托盤圖標(biāo)源碼1
?? JAVA
字號(hào):
/***
 * Windows Tray Icon
 * -----------------
 *
 * Written by Jan Struyf
 *
 *  jan.struyf@cs.kuleuven.ac.be
 *  http://jeans.studentenweb.org/java/trayicon/trayicon.html
 *
 * Please mail me if you
 *	- 've found bugs
 *	- like this program
 *	- don't like a particular feature
 *	- would like something to be modified
 *
 * I always give it my best shot to make a program useful and solid, but
 * remeber that there is absolutely no warranty for using this program as
 * stated in the following terms:
 *
 * THERE IS NO WARRANTY FOR THIS PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
 * LAW. THE COPYRIGHT HOLDER AND/OR OTHER PARTIES WHO MAY HAVE MODIFIED THE
 * PROGRAM, PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
 * EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
 * TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
 * PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
 * REPAIR OR CORRECTION.
 *
 * IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL ANY COPYRIGHT HOLDER,
 * OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM,
 * BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
 * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
 * PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
 * INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
 * PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
 * PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
 *
 * May the Force be with you... Just compile it & use it!
 */

package demo.awt;

import java.awt.*;
import java.awt.event.*;
import java.io.*;

import com.jeans.trayicon.*;

// Demo app for Java Tray Icon
public class TestTrayIcon extends Frame {

    public final static int ENABLE_ITEM = 0;
    public final static int BOLD_ITEM = 1;
    public final static int CHECK_ITEM = 2;

	// App uses 4 icons
	private TrayIconButton icon[];
	// Buttons for exit, hide window and about box
	private Button exit_bt, hide_bt, about_bt;

	public TestTrayIcon() throws TrayIconException, InterruptedException {
		// Create new frame with title
		super("Test Icon");
		setBackground(SystemColor.control);
		// Set callback method to send windows messages through Tray Icon library (see WindowsMessageCallback)
		WindowsTrayIcon.setWindowsMessageCallback(new WindowsMessageCallback());
		// Layout stuff
		setLayout(new GridLayout(0,1,3,3));
		// Load 16x16 icon gif
		setIconImage(loadImage("Duke16.gif"));
		// Create 4 checkboxes with icons: Printer, Battery, France & MS-DOS
		icon = new TrayIconButton[4];
		add(icon[0] = new TrayIconButton("Duke",loadImage("Duke16.gif"),16,16));		
		add(icon[1] = new TrayIconButton("Printer",loadImage("Printer.gif"),16,16));
		add(icon[2] = new TrayIconButton("France",loadImage("France.gif"),16,16));
		add(icon[3] = new TrayIconButton("MS-DOS",loadImage("MsDos.gif"),16,16));
		// Tray Icon left mouse button event restores the main window (make it visible again/requests focus
		RestoreListener listener = new RestoreListener(false);
		for (int k = 0; k < 4; k++) icon[k].addActionListener(listener);
		// Panel with exit, hide & about button - With hide you can hide the main window and restore it
		// by clicking on one of the Tray Icons
		Panel panel = new Panel();
		panel.setLayout(new GridLayout(1,0,3,3));
		panel.add(exit_bt = new Button("Exit"));
		exit_bt.addActionListener(new ExitListener());
		panel.add(hide_bt = new Button("Hide"));
		hide_bt.addActionListener(new HideListener());
		panel.add(about_bt = new Button("About"));
		about_bt.addActionListener(new AboutListener());
		// Each icon has it's own popup menu
		// Because the menu's contain state information, you can't use the same menu for different icons)
		icon[0].setPopup(makePopup());
		icon[1].setPopup(makePopup());
		icon[2].setPopup(makePopup());
		icon[3].setPopup(makePopup());
		add(panel);
		pack();
		validate();
		// Exit if click on close button
		addWindowListener(new ExitWindowListener());
	}

	// Create the popup menu for each Tray Icon (on right mouse click)
	public TrayIconPopup makePopup() {
		// Make new popup menu
		TrayIconPopup popup = new TrayIconPopup();
		// Add show, about, submenu, separator & exit item
		TrayIconPopupSimpleItem item = new TrayIconPopupSimpleItem("&Show");
		item.setDefault(true);
		// Each menu item can have it's own ActionListener		
		item.addActionListener(new RestoreListener(true));
		popup.addMenuItem(item);
		item = new TrayIconPopupSimpleItem("&About");
		item.addActionListener(new AboutListener());
		popup.addMenuItem(item);
		// Create a submenu with title enable and items check 1 & check 2
		TrayIconPopup sub = new TrayIconPopup("&Options");
		// Create and add two checkbox menu items
		TrayIconPopupCheckItem test = new TrayIconPopupCheckItem("Test");
		sub.addMenuItem(test);
		sub.addMenuItem(new TrayIconPopupSeparator());
		TrayIconPopupCheckItem ena = new TrayIconPopupCheckItem("Enable Test");
        	ena.addActionListener(new ChangeMenuListener(test, ENABLE_ITEM));			
		ena.setCheck(true);
		sub.addMenuItem(ena);
		TrayIconPopupCheckItem bold = new TrayIconPopupCheckItem("Bold Test");
	        bold.addActionListener(new ChangeMenuListener(test, BOLD_ITEM));
		sub.addMenuItem(bold);
		TrayIconPopupCheckItem check = new TrayIconPopupCheckItem("Check Test");
        	check.addActionListener(new ChangeMenuListener(test, CHECK_ITEM));
	        test.addActionListener(new ChangeMenuListener(check, CHECK_ITEM));
		sub.addMenuItem(check);		
		// Add submenu to the main menu
		popup.addMenuItem(sub);
		// Add a separator		
		popup.addMenuItem(new TrayIconPopupSeparator());
		// Add exit item
		item = new TrayIconPopupSimpleItem("E&xit");
		item.addActionListener(new ExitListener());
		popup.addMenuItem(item);
		return popup;
	}

	// Load a gif image (used for loading the 16x16 icon gifs)
	public static Image loadImage(String fileName) {
		return Toolkit.getDefaultToolkit().getImage("demo"+File.separator+"images"+File.separator+fileName);
	}

	// Main proc
	public static void main(String[] args) {
		try {
			String appName = "TestTray";
			// First check if there's another instance of our app running by sending a windows message
			// to a hidden icon window "TestTray" - each Tray Icon app has a hidden window that receives
			// the mouse/menu messages for it's Tray Icons
			long result = WindowsTrayIcon.sendWindowsMessage(appName, 1234);
			if (result != -1) {
				// If window exists, there's already an instance of our app running
				// Print message and exit (other app will restore its window when receiving
				// our message - see WindowsMessageCallback
				System.out.println("Already running other instance of "+appName+" (returns: "+result+")");
				return;
			}
			// Init the Tray Icon library given the name for the hidden window
			WindowsTrayIcon.initTrayIcon(appName);
			// Show our main window
			TestTrayIcon test = new TestTrayIcon();
			TestTrayIcon.centerDialog(test);
			test.show();
		} catch (TrayIconException e) {
			System.out.println("Error: "+e.getMessage());
		} catch (InterruptedException e) {
		}
	}
	
    public void doExit() {	
        System.out.println("Exit selected.");
		// Free all Tray Icon resources - always call this on exit
		WindowsTrayIcon.cleanUp();
        // Exit application
		System.exit(0);
    }
	
	public void doHide(boolean exitOnFail) {
        System.out.println("Hide selected.");
		// Check if there's a Tray Icon visible
		// Hide works only when there's an icon in the system tray
        boolean visible = true;
        for (int k = 0; k < 4; k++) {
		    if (icon[k].testVisible()) visible = false;
		}
		setVisible(visible);
        if (visible == true) {
            System.out.println("Hide works only when there's an icon in the system tray.");            
            if (exitOnFail) doExit();
        }
    }
        
	public static void centerDialog(Window frame) {
		Dimension dialogSize = frame.getSize();
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		frame.setLocation(screenSize.width/2 - dialogSize.width/2,
		                  screenSize.height/2 - dialogSize.height/2);
	}    
	
	// Callback listener handles incomming windows messages. In this demo, a windows message is send when the
	// user tries to start a second instance of the demo app. You can try this one by opening two MS-DOS prompts
	// and say in each one "java demo.awt.TestTrayIcon"
	// MS-DOS 1:
	// 	C:\TrayIcon>java demo.awt.TestTrayIcon
	//	...
	//	Other instance started (parameter: 1234)
	//
	// MS-DOS 2:
	// 	C:\TrayIcon>java demo.awt.TestTrayIcon
	// 	Already running other instance of TestTray (returns: 4321)
	private class WindowsMessageCallback implements TrayIconCallback {

		public int callback(int param) {
			// Param contains the integer value send with sendWindowsMessage(appName, param)
			System.out.println("Other instance started (parameter: "+param+")");
			setVisible(true);
			requestFocus();
			// Return integer value to other process
			return 4321;
		}

	}

	// Callback listener handles exit button / exit popup menu
	private class ExitListener implements ActionListener {

		public void actionPerformed(ActionEvent evt) {
		    doExit();
		}

	}

	// Callback listener handles restore (click left on any icon / show popup menu)
	private class RestoreListener implements ActionListener {

        protected boolean from_menu;

        public RestoreListener(boolean fromMenu) {
            from_menu = fromMenu;
        }

		public void actionPerformed(ActionEvent evt) {
			if (from_menu) System.out.println("Restore selected..");
			else System.out.println("Tray icon button pressed..");
			// Make main window visible if it was hidden
			setVisible(true);
			// Request input focus
			requestFocus();
		}

	}

	// Callback listener for hide button
	private class HideListener implements ActionListener {

		public void actionPerformed(ActionEvent evt) {
		    doHide(false);
		}

	}

	// Callback listener handles about button
	private class AboutListener implements ActionListener {

		public void actionPerformed(ActionEvent evt) {
			System.out.println("About selected..");
			TrayAboutBox box = new TrayAboutBox(TestTrayIcon.this);
			centerDialog(box);
			box.show();
		}

	}

	// Callback listener handles window close button
	private class ExitWindowListener extends WindowAdapter {

		public void windowClosing(WindowEvent evt) {
			// Free all Tray Icon resources - always call this on exit
			WindowsTrayIcon.cleanUp();
			System.exit(0);
		}
	}
	
	// Callback listener handles restore (click left on any icon / show popup menu)
	private class ChangeMenuListener implements ActionListener {

        protected TrayIconPopupCheckItem m_Item;
        protected int m_Change;

        public ChangeMenuListener(TrayIconPopupCheckItem item, int change) {
            m_Item = item;
            m_Change = change;
        }

		public void actionPerformed(ActionEvent evt) {
		    TrayIconPopupCheckItem source = (TrayIconPopupCheckItem)evt.getSource();
			boolean value = source.getCheck();
			switch (m_Change) {
			    case ENABLE_ITEM:
			        m_Item.setEnabled(value); break;
			    case BOLD_ITEM:
			        m_Item.setDefault(value); break;
			    case CHECK_ITEM:
			        m_Item.setCheck(value); break;
			}
		}
	}		
}

// Panel with checkbox, string and icon
class TrayIconButton extends Panel {

	// The checkbox for enabling this Tray Icon
	Checkbox button;
	// The Tray Icon's class
	WindowsTrayIcon icon;

	// Create new panel with checkbox, string and icon
	// Name = Printer/France/Battery/MS-DOS
	// Image = 16x16 Icon gif
	// Wd = 16, Hi = 16
	public TrayIconButton(String name, Image image, int wd, int hi) throws TrayIconException, InterruptedException {
		setLayout(new BorderLayout(3,3));
		// Add icon image in ImageDisplayer
		add(new ImageDisplayer(image, wd, hi), BorderLayout.EAST);
		// Add checkbox for enabling Tray Icon
		add(button = new Checkbox(name), BorderLayout.CENTER);
		button.addItemListener(new ToggleListener());
		// Create Tray Icon and set tooltip
		icon = new WindowsTrayIcon(image, wd, hi);
		icon.setToolTipText(name);
	}

	// Add popup menu to Tray Icon
	public void setPopup(TrayIconPopup popup) {
		icon.setPopup(popup);
	}

	// Add action listener to Tray Icon
	public void addActionListener(ActionListener listener) {
		icon.addActionListener(listener);
	}

	// Icon visible?
	public boolean testVisible() {
		return icon.isVisible();
	}

	// Listener for checkbox
	// Make icon visible/invisible depending on checkbox state
	private class ToggleListener implements ItemListener {

		public void itemStateChanged(ItemEvent evt) {
			icon.setVisible(evt.getStateChange() == ItemEvent.SELECTED);
		}

	}

}

// Canvas for displaying images with given size
class ImageDisplayer extends Canvas {

	// The image to display
	Image image;
	// The images size
	int wd, hi;

	// Create new canvas with given image and size
	public ImageDisplayer(Image image, int wd, int hi) {
		this.image = image;
		this.wd = wd;
		this.hi = hi;
	}

	// Pref size for layout manager
	public Dimension getPreferredSize() {
		return new Dimension(wd, hi);
	}

	// Min size for layout manager
	public Dimension getMinimumSize() {
		return new Dimension(wd, hi);
	}

	// Redraw image (don't clear background first!)
	public void update(Graphics g) {
		paint(g);
	}

 	// Redraw image
	public void paint(Graphics g) {
		g.drawImage(image, 0, 0, this);
	}
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美一区二区在线视频| 亚洲国产精华液网站w| 91国偷自产一区二区开放时间| 国产精品一区二区无线| 精品一区二区影视| 毛片av一区二区| 国产一区二区三区最好精华液| 久久99热99| 国产乱码精品1区2区3区| 国产成人精品亚洲日本在线桃色| 国产在线视频一区二区| 国产激情精品久久久第一区二区 | 99久久精品免费看国产免费软件| 国产成人鲁色资源国产91色综 | 丁香六月综合激情| 北条麻妃一区二区三区| 99精品国产91久久久久久| 色婷婷av一区| 制服.丝袜.亚洲.另类.中文| 欧美狂野另类xxxxoooo| 欧美久久久久免费| 欧美成人免费网站| 国产精品热久久久久夜色精品三区| 中文字幕一区视频| 一区二区三区在线高清| 日韩精品一级中文字幕精品视频免费观看 | 精品午夜久久福利影院| 国产成人在线视频免费播放| 99久久婷婷国产| 欧美视频日韩视频在线观看| 日韩限制级电影在线观看| 国产亚洲综合性久久久影院| 中文字幕日本不卡| 五月天久久比比资源色| 久久电影国产免费久久电影| 成人av免费在线| 欧美久久久影院| 久久久精品国产免大香伊| 成人免费在线观看入口| 天天影视色香欲综合网老头| 国产一区二区三区在线观看精品 | 欧美日韩大陆在线| 久久综合久久鬼色中文字| 亚洲色图清纯唯美| 免费成人av在线播放| 粉嫩aⅴ一区二区三区四区| 欧美色图激情小说| 久久蜜桃av一区精品变态类天堂 | 国产一区二区不卡老阿姨| 99在线精品一区二区三区| 91精品国产综合久久久久久久久久| 久久久精品人体av艺术| 亚洲图片一区二区| 国产成人免费在线观看| 制服丝袜中文字幕一区| 国产精品久久久99| 青青草一区二区三区| 色一情一伦一子一伦一区| 日韩精品一区二区三区三区免费| 综合分类小说区另类春色亚洲小说欧美| 午夜精品视频一区| 成a人片国产精品| 欧美mv日韩mv国产网站| 亚洲精品视频一区二区| 国产一区二三区| 欧美理论电影在线| 亚洲天堂成人在线观看| 国产真实乱子伦精品视频| 欧美男生操女生| 亚洲精品午夜久久久| 国产精品系列在线观看| 欧美精品一级二级三级| 亚洲欧美另类在线| 国产一区二区美女诱惑| 日韩一区二区免费视频| 亚洲综合精品自拍| av不卡免费在线观看| 久久女同精品一区二区| 日韩av电影免费观看高清完整版在线观看| 成人精品国产一区二区4080| 久久色成人在线| 日韩av中文字幕一区二区| 一本大道久久a久久综合婷婷| 国产精品毛片a∨一区二区三区| 麻豆精品蜜桃视频网站| 欧美一区永久视频免费观看| 一区二区激情小说| 92国产精品观看| 亚洲欧洲av在线| 成人国产在线观看| 国产视频在线观看一区二区三区| 韩国女主播成人在线| 69久久夜色精品国产69蝌蚪网| 一区二区日韩av| 欧美性猛交一区二区三区精品| 日韩伦理av电影| 91麻豆精品一区二区三区| 国产精品乱人伦| 成人午夜精品在线| 国产精品视频一二三区 | 精品久久久久av影院 | 日韩欧美一区在线| 美女高潮久久久| 日韩欧美电影一区| 久草热8精品视频在线观看| 欧美一区二区视频免费观看| 强制捆绑调教一区二区| 91精品国产综合久久香蕉麻豆| 亚洲bt欧美bt精品| 欧美蜜桃一区二区三区| 视频一区二区三区在线| 91麻豆精品国产自产在线观看一区 | 色天天综合色天天久久| 一区二区三区四区视频精品免费| 一本大道久久a久久综合婷婷| 一区二区在线观看免费视频播放| 在线一区二区三区四区五区| 亚洲在线观看免费视频| 欧美人成免费网站| 蜜臀久久久久久久| 26uuu国产在线精品一区二区| 久久99精品久久久久久| 国产片一区二区| 99久久婷婷国产| 亚洲成人久久影院| 日韩欧美不卡在线观看视频| 国内精品久久久久影院薰衣草 | 亚洲一二三四区不卡| 欧美精品乱码久久久久久按摩| 免费观看成人鲁鲁鲁鲁鲁视频| 久久婷婷色综合| k8久久久一区二区三区| 一区二区三区日韩欧美精品| 欧美日韩一区高清| 麻豆国产精品一区二区三区 | 九色|91porny| 国产精品麻豆欧美日韩ww| 91成人免费在线| 免费看欧美美女黄的网站| 国产女人18水真多18精品一级做 | 亚洲精品在线免费观看视频| 成人三级伦理片| 亚洲国产一区二区视频| 精品噜噜噜噜久久久久久久久试看| 成人高清免费观看| 午夜成人在线视频| 久久久久久久久久看片| 91麻豆免费观看| 久草精品在线观看| 亚洲欧美日韩综合aⅴ视频| 欧美一级xxx| 99精品欧美一区二区三区小说 | 波多野结衣精品在线| 成人av一区二区三区| 亚洲一区在线观看视频| 久久人人爽爽爽人久久久| 日本乱人伦aⅴ精品| 国产一级精品在线| 亚洲裸体xxx| 久久久影院官网| 欧美丰满少妇xxxxx高潮对白| 成熟亚洲日本毛茸茸凸凹| 免费在线观看一区| 亚洲人成精品久久久久久| 精品伦理精品一区| 欧美日韩一区二区不卡| 成人动漫精品一区二区| 奇米精品一区二区三区在线观看| 亚洲欧美日韩在线不卡| 久久精品日韩一区二区三区| 欧美日韩mp4| 色视频一区二区| 国产sm精品调教视频网站| 日韩综合在线视频| 亚洲美女少妇撒尿| 国产午夜亚洲精品不卡| 欧美大肚乱孕交hd孕妇| 欧美伊人久久久久久午夜久久久久| 国产·精品毛片| 蜜臂av日日欢夜夜爽一区| 一区二区三区在线免费视频| 国产精品网站导航| 久久久国产精华| 日韩欧美中文字幕公布| 欧美乱妇15p| 欧美亚洲国产一区在线观看网站| 成人福利电影精品一区二区在线观看| 美女高潮久久久| 奇米精品一区二区三区四区 | 日本在线播放一区二区三区| 亚洲一区影音先锋| 亚洲欧美视频在线观看视频| 国产精品久久久久久久久久久免费看 | 欧美在线一区二区| www.爱久久.com| 成人免费毛片片v| 粉嫩av亚洲一区二区图片| 国产精品亚洲а∨天堂免在线| 国产真实乱子伦精品视频| 久热成人在线视频|