⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 startittray.java

📁 SRI international 发布的OAA框架软件
💻 JAVA
字号:
/**
 * The contents of this file are subject to the OAA  Community Research
 * License Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License
 * at http://www.ai.sri.com/~oaa/.  Software distributed under the License
 * is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * rights and limitations under the License.  Portions of the software are
 * Copyright (c) SRI International, 1999-2003.  All rights reserved.
 * "OAA" is a registered trademark, and "Open Agent Architecture" is a
 * trademark, of SRI International, a California nonprofit public benefit
 * corporation.
 */

package com.sri.oaa2.agt.startit;

import com.jeans.trayicon.*;

import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;

public class StartitTray {
    private static final String APP_NAME = "StartIt";
    private static final String IMAGE_NAME = "com/sri/oaa2/agt/startit/images/startit16.gif";
    private static final int IMAGE_WIDTH = 16;
    private static final int IMAGE_HEIGHT = 16;
    private static final String HIDE_SHOW_NAME = "Hide/Show StartIt";
    private static final String EXIT_NAME = "Exit";

    public static void main(String args[]) {
        // Create Startit
        final Startit startit = new Startit(args);
        // Load icon
        URL startitUrl = ClassLoader.getSystemResource(IMAGE_NAME);
        Image startitImage = Toolkit.getDefaultToolkit().getImage(startitUrl);
        // Create popup menu
        TrayIconPopup popup = new TrayIconPopup();
        TrayIconPopupSimpleItem hideShowItem = new TrayIconPopupSimpleItem(HIDE_SHOW_NAME);
        // Hide/Show StartIt
        hideShowItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent actionevent) {
                startit.setVisible(!startit.isVisible());
            }
        });
        popup.addMenuItem(hideShowItem);
        // Exit
        TrayIconPopupSimpleItem exitItem = new TrayIconPopupSimpleItem(EXIT_NAME);
        exitItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent actionevent) {
                startit.quit();
            }
        });
        popup.addMenuItem(exitItem);
        // Create task tray icon
        try {
            WindowsTrayIcon.initTrayIcon(APP_NAME);
            WindowsTrayIcon startitIcon = new WindowsTrayIcon(startitImage, IMAGE_WIDTH, IMAGE_HEIGHT);
            startitIcon.setPopup(popup);
            startitIcon.setToolTipText(APP_NAME);
            startitIcon.setVisible(true);
        } catch (Exception e) {
            System.err.println("Exception: " + e.getMessage());
            e.printStackTrace();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -