Search in sources :

Example 21 with MenuItem

use of java.awt.MenuItem in project fql by CategoricalData.

the class GUI method populateFpql.

private static void populateFpql(Menu menu) {
    MenuItem enrichItem = new MenuItem("FPQL Enrich");
    menu.add(enrichItem);
    enrichItem.addActionListener(x -> new EnrichViewer());
    MenuItem raItem = new MenuItem("RA to FPQL");
    menu.add(raItem);
    raItem.addActionListener(x -> new XRaToFpql());
    MenuItem sqlItem = new MenuItem("SQL to FPQL");
    menu.add(sqlItem);
    sqlItem.addActionListener(x -> new XSqlToFql());
    MenuItem jsonItem = new MenuItem("JSON to FPQL");
    menu.add(jsonItem);
    jsonItem.addActionListener(x -> new XJsonToFQL());
    MenuItem neo4j = new MenuItem("Neo4j to FPQL");
    menu.add(neo4j);
    neo4j.addActionListener(x -> new XNeo4jToFQL());
    MenuItem easik = new MenuItem("EASIK to FPQL");
    menu.add(easik);
    easik.addActionListener(x -> new XEasikToFQL());
}
Also used : XRaToFpql(catdata.fpql.XRaToFpql) XEasikToFQL(catdata.fpql.XEasikToFQL) XSqlToFql(catdata.fpql.XSqlToFql) EnrichViewer(catdata.fpql.EnrichViewer) XNeo4jToFQL(catdata.fpql.XNeo4jToFQL) MenuItem(java.awt.MenuItem) XJsonToFQL(catdata.fpql.XJsonToFQL)

Example 22 with MenuItem

use of java.awt.MenuItem in project openblocks by mikaelhg.

the class ContextMenu method initAddCommentMenu.

/**
 * Initializes the context menu for adding Comments.
 */
private static void initAddCommentMenu() {
    addCommentItem = new MenuItem("Add Comment");
    addCommentItem.setActionCommand(ADD_COMMENT_BLOCK);
    addCommentItem.addActionListener(rndBlockMenu);
    addCommentMenu.add(addCommentItem);
    addCommentMenuInit = true;
}
Also used : MenuItem(java.awt.MenuItem)

Example 23 with MenuItem

use of java.awt.MenuItem in project openblocks by mikaelhg.

the class ContextMenu method initCanvasMenu.

/**
 * Initializes the context menu for the BlockCanvas
 */
private static void initCanvasMenu() {
    // TODO some workspaces don't have pages
    arrangeAllBlocks = new MenuItem("Organize all blocks");
    arrangeAllBlocks.setActionCommand(ARRANGE_ALL_BLOCKS);
    arrangeAllBlocks.addActionListener(canvasMenu);
    canvasMenu.add(arrangeAllBlocks);
    canvasMenuInit = true;
}
Also used : MenuItem(java.awt.MenuItem)

Example 24 with MenuItem

use of java.awt.MenuItem in project SKMCLauncher by SKCraft.

the class GameConsoleFrame method setupTrayIcon.

private boolean setupTrayIcon() {
    if (!SystemTray.isSupported() || trayOkImage == null || trayClosedImage == null) {
        return false;
    }
    trayIcon = new TrayIcon(trayOkImage);
    trayIcon.setImageAutoSize(true);
    trayIcon.setToolTip("Messages and Errors for SKMCLauncher");
    trayIcon.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            reshow();
        }
    });
    PopupMenu popup = new PopupMenu();
    MenuItem item;
    popup.add(item = new MenuItem("SKMCLauncher"));
    item.setEnabled(false);
    popup.add(item = new MenuItem("Show messages and errors"));
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            reshow();
        }
    });
    popup.add(item = new MenuItem("Kill game"));
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            tryKill();
        }
    });
    trayIcon.setPopupMenu(popup);
    try {
        SystemTray tray = SystemTray.getSystemTray();
        tray.add(trayIcon);
        return true;
    } catch (AWTException e) {
    }
    return false;
}
Also used : ActionListener(java.awt.event.ActionListener) TrayIcon(java.awt.TrayIcon) ActionEvent(java.awt.event.ActionEvent) SystemTray(java.awt.SystemTray) MenuItem(java.awt.MenuItem) PopupMenu(java.awt.PopupMenu) AWTException(java.awt.AWTException)

Example 25 with MenuItem

use of java.awt.MenuItem in project yyl_example by Relucent.

the class TrayIconTest method main.

public static void main(String[] args) {
    // 判断是否支持系统托盘
    if (!SystemTray.isSupported()) {
        JOptionPane.showMessageDialog(null, "SystemTray is not support !");
    }
    // 获得Image对象
    byte[] imagedata = IoUtil.toByteArray(TrayIconTest.class.getResourceAsStream("ICO128.png"), true);
    Image image = Toolkit.getDefaultToolkit().createImage(imagedata);
    // 创建托盘图标
    TrayIcon trayIcon = new TrayIcon(image);
    // 自适应图标大小
    trayIcon.setImageAutoSize(true);
    // 添加工具提示文本
    trayIcon.setToolTip("Hello");
    // 创建弹出菜单
    PopupMenu popupMenu = new PopupMenu();
    popupMenu.add(new MenuItem("Item1"));
    popupMenu.add(new MenuItem("Item2"));
    popupMenu.add(new MenuItem("Item3"));
    popupMenu.addSeparator();
    popupMenu.add(new MenuItem("Item4"));
    popupMenu.add(new MenuItem("Item5"));
    popupMenu.addSeparator();
    MenuItem closeMenuItem = new MenuItem("Close");
    popupMenu.add(closeMenuItem);
    // 为托盘图标加弹出菜弹
    trayIcon.setPopupMenu(popupMenu);
    // 添加事件
    trayIcon.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            // 判断是否双击了鼠标
            if (e.getClickCount() == 2) {
                JOptionPane.showMessageDialog(null, "double-click");
            }
        }
    });
    closeMenuItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            SystemTray.getSystemTray().remove(trayIcon);
            System.exit(0);
        }
    });
    // 获得系统托盘对象
    SystemTray systemTray = SystemTray.getSystemTray();
    try {
        // 为系统托盘加托盘图标
        systemTray.add(trayIcon);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : MouseEvent(java.awt.event.MouseEvent) ActionEvent(java.awt.event.ActionEvent) SystemTray(java.awt.SystemTray) MouseAdapter(java.awt.event.MouseAdapter) MenuItem(java.awt.MenuItem) Image(java.awt.Image) ActionListener(java.awt.event.ActionListener) TrayIcon(java.awt.TrayIcon) PopupMenu(java.awt.PopupMenu)

Aggregations

MenuItem (java.awt.MenuItem)53 PopupMenu (java.awt.PopupMenu)24 Menu (java.awt.Menu)15 JMenuItem (javax.swing.JMenuItem)15 JPopupMenu (javax.swing.JPopupMenu)13 TrayIcon (java.awt.TrayIcon)12 AWTException (java.awt.AWTException)9 MenuShortcut (java.awt.MenuShortcut)9 ActionEvent (java.awt.event.ActionEvent)9 ActionListener (java.awt.event.ActionListener)9 CheckboxMenuItem (java.awt.CheckboxMenuItem)8 Image (java.awt.Image)8 SystemTray (java.awt.SystemTray)8 IOException (java.io.IOException)6 Dimension (java.awt.Dimension)5 File (java.io.File)4 BorderLayout (java.awt.BorderLayout)3 FileDialog (java.awt.FileDialog)3 URL (java.net.URL)3 SQLException (java.sql.SQLException)3