Example usage for java.awt.event MouseEvent BUTTON1

List of usage examples for java.awt.event MouseEvent BUTTON1

Introduction

In this page you can find the example usage for java.awt.event MouseEvent BUTTON1.

Prototype

int BUTTON1

To view the source code for java.awt.event MouseEvent BUTTON1.

Click Source Link

Document

Indicates mouse button #1; used by #getButton .

Usage

From source file:se.trixon.mapollage.ui.MainFrame.java

private void menuButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_menuButtonMousePressed
    if (evt == null || evt.getButton() == MouseEvent.BUTTON1) {
        if (mPopupMenu.isVisible()) {
            mPopupMenu.setVisible(false);
        } else {//from   w  ww  . j av a2  s .  c  o  m
            mPopupMenu.show(menuButton, menuButton.getWidth() - mPopupMenu.getWidth(), mPopupMenu.getHeight());

            int x = menuButton.getLocationOnScreen().x + menuButton.getWidth() - mPopupMenu.getWidth();
            int y = menuButton.getLocationOnScreen().y + menuButton.getHeight();

            mPopupMenu.setLocation(x, y);
        }
    }
}

From source file:net.sf.firemox.clickable.target.card.MCard.java

@Override
public void mouseClicked(MouseEvent e) {
    if (!(getParent() instanceof MZone) && !(getParent() instanceof MCard)) {
        return;/* w  w w  .  j  a va  2s. co  m*/
    }
    StackManager.noReplayToken.take();
    MZone container = getContainer();
    try {
        TargetFactory.triggerTargetable = this;
        if (ConnectionManager.isConnected() && e.getButton() == MouseEvent.BUTTON1) {
            // only if left button is pressed
            if (!StackManager.actionManager.clickOn(this)) {
                // this card is activated and you control it
                if (!(StackManager.actionManager.currentAction instanceof WaitingAbility)) {
                    // we are not waiting ability
                    if (container instanceof ExpandableZone) {
                        ((ExpandableZone) container).toggle();
                    }
                    return;
                }
                final List<Ability> abilities = ((WaitingAbility) StackManager.actionManager.currentAction)
                        .abilitiesOf(this);
                final List<Ability> advAbilities = ((WaitingAbility) StackManager.actionManager.currentAction)
                        .advancedAbilitiesOf(this);

                // is there any playable ability with this card ?
                if ((abilities == null || abilities.isEmpty())
                        && (advAbilities == null || advAbilities.isEmpty())) {
                    // no playable ability, and this card is not wait for -> toggle
                    if (container instanceof ExpandableZone) {
                        ((ExpandableZone) container).toggle();
                    }
                    return;
                }

                // a choice has to be made
                if (advAbilities != null && !advAbilities.isEmpty()
                        || abilities != null && abilities.size() > 1) {
                    /*
                     * several abilities for this card, we fill the popup ability menu
                     */
                    TargetFactory.abilitiesMenu.removeAll();
                    if (abilities != null) {
                        for (Ability ability : abilities) {
                            final JMenuItem item = new JMenuItem(
                                    "<html>" + ability.toHtmlString(null) + "</html>");
                            item.addActionListener(this);
                            TargetFactory.abilitiesMenu.add(item);
                        }
                    }
                    if (advAbilities != null && !advAbilities.isEmpty()) {
                        TargetFactory.abilitiesMenu.add(new JSeparator());
                        for (Ability ability : advAbilities) {
                            final JMenuItem item = new JMenuItem(
                                    "<html>" + ability.toHtmlString(null) + "</html>", WARNING_PICTURE);
                            item.addActionListener(this);
                            TargetFactory.abilitiesMenu.add(item);
                        }
                    }
                    // show the option popup menu
                    TargetFactory.abilitiesMenu.show(e.getComponent(), e.getX(), e.getY());
                    return;
                } else if (abilities != null && abilities.size() == 1
                        && (advAbilities == null || advAbilities.isEmpty())) {
                    // only one playable ability, we select it automatically
                    ((UserAbility) abilities.get(0)).mouseClicked(0);
                }
            } else if (StackManager.idHandedPlayer != 0) {
                if (container instanceof ExpandableZone) {
                    ((ExpandableZone) container).toggle();
                }
            } else {
                // Since this click has been handled, the opponent will be informed on
                sendClickToOpponent();
                StackManager.actionManager.succeedClickOn(this);
            }
        } else if (ConnectionManager.isConnected()) {
            // only if not left button is pressed
            CardFactory.contextMenu.removeAll();
            TargetFactory.triggerTargetable = this;

            // add counter item
            CardFactory.countItem.setText(LanguageManager.getString("countcard", container.toString(),
                    String.valueOf(container.getCardCount())));
            CardFactory.contextMenu.add(CardFactory.countItem);

            // add refresh picture item
            CardFactory.contextMenu.add(CardFactory.reloadPictureItem);

            // add expand/gather item
            if (container instanceof ExpandableZone) {
                if (container == ZoneManager.expandedZone) {
                    CardFactory.contextMenu.add(CardFactory.gatherItem);
                } else {
                    CardFactory.contextMenu.add(CardFactory.expandItem);
                }
            }
            CardFactory.contextMenu.add(new JSeparator());

            // add the "database" item --> activate the tabbed panel
            CardFactory.contextMenu.add(CardFactory.databaseCardInfoItem);

            // TODO add "java properties" item --> show an inspect popup.
            // CardFactory.contextMenu.add(CardFactory.javaDebugItem);

            // TODO add "show id" option

            // show the option popup menu
            CardFactory.contextMenu.show(e.getComponent(), e.getX(), e.getY());
        }
    } catch (Throwable t) {
        t.printStackTrace();
    } finally {
        StackManager.noReplayToken.release();
    }
}

From source file:uk.ac.lkl.cram.ui.ModuleFrame.java

private JXTaskPane createLearnerFeedbackChartPane() {
    JXTaskPane feedbackChartPane = new JXTaskPane();
    feedbackChartPane.setScrollOnExpand(true);
    feedbackChartPane.setTitle("Learner Feedback");
    FeedbackChartMaker maker = new FeedbackChartMaker(module);
    final ChartPanel chartPanel = maker.getChartPanel();
    //Add a mouselistener, listening for a double click on a bar of the stacked bar
    chartPanel.addChartMouseListener(new ChartMouseListener() {
        @Override/*w  ww. j  av a  2 s  . c  o m*/
        public void chartMouseClicked(ChartMouseEvent cme) {
            //Get the mouse event
            MouseEvent trigger = cme.getTrigger();
            //Test if the mouse event is a left-button
            if (trigger.getButton() == MouseEvent.BUTTON1 && trigger.getClickCount() == 2) {

                //Create a pop up dialog containing that the tlalineitems
                FeedbackPopupDialog popup = new FeedbackPopupDialog(
                        (Frame) SwingUtilities.getWindowAncestor(chartPanel), true, module.getTLALineItems());
                //Set the title of the popup 
                popup.setTitle("All Activities");
                //Centre the popup at the location of the mouse click
                Point location = trigger.getLocationOnScreen();
                int w = popup.getWidth();
                int h = popup.getHeight();
                popup.setLocation(location.x - w / 2, location.y - h / 2);
                popup.setVisible(true);
                int returnStatus = popup.getReturnStatus();
                if (returnStatus == LearningTypePopupDialog.RET_OK) {
                    modifyTLALineItem(popup.getSelectedTLALineItem(), 1);
                }
            }
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent cme) {
            //Set the cursor shape according to the location of the cursor
            if (cme.getEntity() instanceof CategoryItemEntity) {
                chartPanel.setCursor(HAND);
            } else {
                chartPanel.setCursor(Cursor.getDefaultCursor());
            }
        }
    });
    chartPanel.setPreferredSize(new Dimension(150, 200));
    feedbackChartPane.add(chartPanel);
    return feedbackChartPane;
}

From source file:gtu._work.ui.DirectoryCompareUI.java

private void dirCompareTableMouseClicked(MouseEvent evt) {
    try {/*from  ww  w.j av a2 s .co  m*/
        final JTableUtil util = JTableUtil.newInstance(dirCompareTable);
        InfoObj obj = getInfoObj(util.getSelectedRow(), util);

        if (evt.getClickCount() == 2 && evt.getButton() == MouseEvent.BUTTON1) {
            File mainFile = obj.mainFile.getFile().exists() ? obj.mainFile.getFile() : NOT_EXIST_FILE;
            File compareFile = obj.compareToFile.getFile().exists() ? obj.compareToFile.getFile()
                    : NOT_EXIST_FILE;

            File fileA = mainFile;
            File fileB = compareFile;
            if (mergeSwap) {
                File tempFile = fileA;
                fileA = fileB;
                fileB = tempFile;
            }

            DiffMergeCommand diffCommand = (DiffMergeCommand) diffToolComboBox.getSelectedItem();
            String command = diffCommand.getCommand(this, fileA, fileB);
            System.out.println(command);
            ProcessWatcher.newInstance(Runtime.getRuntime().exec(command)).getStreamSync();
        }
        if (evt.getClickCount() == 1 && evt.getButton() == MouseEvent.BUTTON3) {
            final File mainFile = obj.mainFile.getFile();
            final File compareToFile = obj.compareToFile.getFile();

            JPopupMenuUtil.newInstance(dirCompareTable).applyEvent(evt)//
                    .addJMenuItem("", new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            JCommonUtil._jOptionPane_showMessageDialog_info(//
                                    ": " + (mainFile.exists() ? mainFile.getAbsolutePath() : "?")
                                            + //
                            "\n?: " + (compareToFile.exists() ? compareToFile.getAbsolutePath()
                                    : "?"), //
                                    mainFile.getName());
                        }
                    })//
                    .addJMenuItem("merge??:" + (!mergeSwap ? "(?)" : "(?)"),
                            new ActionListener() {
                                @Override
                                public void actionPerformed(ActionEvent e) {
                                    mergeSwap = !mergeSwap;
                                }
                            })//
                    .addJMenuItem(" [open file]", new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            openFile(mainFile);
                        }
                    })//
                    .addJMenuItem(" [open dir]", new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            openFile(mainFile.getParentFile());
                        }
                    })//
                    .addJMenuItem("? [open file]", new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            openFile(compareToFile);
                        }
                    })//
                    .addJMenuItem("? [open dir]", new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            openFile(compareToFile.getParentFile());
                        }
                    })//
                    .addJMenuItem(" -> ? ()", new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            int[] rows = util.getSelectedRows();
                            if (rows != null && rows.length >= 1) {
                                if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption(
                                        "?" + rows.length + ", ?!", "")) {
                                    List<File> fileList = new ArrayList<File>();
                                    for (int ii = 0; ii < rows.length; ii++) {
                                        InfoObj obj = getInfoObj(rows[ii], util);
                                        File mainFile = obj.mainFile.getFile();
                                        File compareToFile = obj.compareToFile.getFile();
                                        overwriteFile(mainFile, compareToFile, fileList);
                                    }
                                    StringBuilder sb = new StringBuilder();
                                    for (File f : fileList) {
                                        sb.append(f + "\n");
                                    }
                                    JCommonUtil._jOptionPane_showMessageDialog_info(sb, "?");
                                }
                            } else {
                                overwriteFile(mainFile, compareToFile, null);
                            }
                        }
                    })//
                    .addJMenuItem("? ->  ()", new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            int[] rows = util.getSelectedRows();
                            if (rows != null && rows.length >= 1) {
                                if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption(
                                        "?" + rows.length + ", ?!", "")) {
                                    List<File> fileList = new ArrayList<File>();
                                    for (int ii = 0; ii < rows.length; ii++) {
                                        InfoObj obj = getInfoObj(rows[ii], util);
                                        File mainFile = obj.mainFile.getFile();
                                        File compareToFile = obj.compareToFile.getFile();
                                        overwriteFile(compareToFile, mainFile, fileList);
                                    }
                                    StringBuilder sb = new StringBuilder();
                                    for (File f : fileList) {
                                        sb.append(f + "\n");
                                    }
                                    JCommonUtil._jOptionPane_showMessageDialog_info(sb, "?");
                                }
                            } else {
                                overwriteFile(compareToFile, mainFile, null);
                            }
                        }
                    })//
                    .addJMenuItem("(?)", new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            pourOutFilesByOrignPath(true);
                        }
                    })//
                    .addJMenuItem("?(?)", new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            pourOutFilesByOrignPath(false);
                        }
                    }).show();
        }
    } catch (Exception e) {
        JCommonUtil.handleException(e, false);
    }
}

From source file:net.sf.firemox.Magic.java

public void mouseClicked(MouseEvent e) {
    Object obj = e.getSource();//from  ww w  .  j  a v  a2  s.  c o m
    if (obj == skipButton) {
        /**
         * invoked by a click directly on the "skip/cancel" of the label".
         * 
         * @param evt
         *          mouse event
         * @see MEventManager#raiseEvent(int,boolean)
         * @see MEventManager#getNextStop()
         * @see MPhase#breakpoint
         * @see MPhase#skipAll
         * @see Magic#manuaSkip()
         */
        // only if enabled and left mouse button pressed
        StackManager.noReplayToken.take();
        try {
            if (ConnectionManager.isConnected() && skipButton.isEnabled()
                    && e.getButton() == MouseEvent.BUTTON1) {
                manualSkip();
            }
        } catch (Throwable t) {
            t.printStackTrace();
        } finally {
            StackManager.noReplayToken.release();
        }
    }
}

From source file:de.codesourcery.jasm16.ide.ui.views.SourceEditorView.java

protected JPanel createPanel() {
    // button panel
    final JToolBar toolbar = new JToolBar();
    toolbar.setLayout(new GridBagLayout());
    setColors(toolbar);/*from   w  w  w  .  j  a  v a 2 s. c om*/

    final JButton showASTButton = new JButton("Show AST");
    setColors(showASTButton);

    showASTButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final boolean currentlyVisible = isASTInspectorVisible();
            if (currentlyVisible) {
                showASTButton.setText("Show AST");
            } else {
                showASTButton.setText("Hide AST");
            }
            if (currentlyVisible) {
                astInspector.setVisible(false);
            } else {
                showASTInspector();
            }

        }
    });

    GridBagConstraints cnstrs = constraints(0, 0, false, true, GridBagConstraints.NONE);
    toolbar.add(showASTButton, cnstrs);

    // navigation history back button
    cnstrs = constraints(1, 0, false, true, GridBagConstraints.NONE);
    toolbar.add(navigationHistoryBack, cnstrs);
    navigationHistoryBack.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            navigationHistoryBack();
        }
    });

    navigationHistoryBack.setEnabled(false);

    // navigation history forward button
    cnstrs = constraints(2, 0, true, true, GridBagConstraints.NONE);
    toolbar.add(navigationHistoryForward, cnstrs);
    navigationHistoryForward.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            navigationHistoryForward();
        }
    });
    navigationHistoryForward.setEnabled(false);

    // create status area
    statusArea.setPreferredSize(new Dimension(400, 100));
    statusArea.setModel(statusModel);
    setColors(statusArea);

    /**
     * TOOLBAR
     * SOURCE
     * cursor position
     * status area 
     */
    final JPanel topPanel = new JPanel();
    topPanel.setLayout(new GridBagLayout());

    cnstrs = constraints(0, 0, GridBagConstraints.HORIZONTAL);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.weighty = 0;
    topPanel.add(toolbar, cnstrs);

    cnstrs = constraints(0, 1, GridBagConstraints.BOTH);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.weighty = 1.0;
    topPanel.add(super.getPanel(), cnstrs);

    final JPanel bottomPanel = new JPanel();
    bottomPanel.setLayout(new GridBagLayout());

    statusArea.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

    statusArea.addMouseListener(new MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                final int viewRow = statusArea.rowAtPoint(e.getPoint());
                if (viewRow != -1) {
                    final int modelRow = statusArea.convertRowIndexToModel(viewRow);
                    StatusMessage message = statusModel.getMessage(modelRow);
                    if (message.getLocation() != null) {
                        moveCursorTo(message.getLocation(), true);
                    }
                }
            }
        };
    });

    EditorContainer.addEditorCloseKeyListener(statusArea, this);

    statusArea.setFillsViewportHeight(true);
    statusArea.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    final JScrollPane statusPane = new JScrollPane(statusArea);
    setColors(statusPane);

    statusPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    statusPane.setPreferredSize(new Dimension(400, 100));
    statusPane.setMinimumSize(new Dimension(100, 20));

    cnstrs = constraints(0, 0, GridBagConstraints.BOTH);
    cnstrs.weightx = 1;
    cnstrs.weighty = 1;
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.gridheight = GridBagConstraints.REMAINDER;

    bottomPanel.add(statusPane, cnstrs);

    // setup result panel
    final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, bottomPanel);
    setColors(splitPane);

    final JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    setColors(panel);
    cnstrs = constraints(0, 0, true, true, GridBagConstraints.BOTH);
    panel.add(splitPane, cnstrs);

    final AncestorListener l = new AncestorListener() {

        @Override
        public void ancestorRemoved(AncestorEvent event) {
        }

        @Override
        public void ancestorMoved(AncestorEvent event) {
        }

        @Override
        public void ancestorAdded(AncestorEvent event) {
            splitPane.setDividerLocation(0.8d);
        }
    };
    panel.addAncestorListener(l);
    return panel;
}

From source file:org.rdv.ui.TimeSlider.java

/**
 * Called when the mouse is clicked. Used to set the time value when there is
 * a click on the time slider./*from  ww  w.ja  v  a2  s. co m*/
 * 
 * @param me  the mouse event that triggered this
 */
public void mouseClicked(MouseEvent me) {
    double time;
    if (me.getSource() == this) {
        time = getTimeFromX(me.getX());
    } else if (me.getSource() == valueButton) {
        time = getTimeFromX(valueButton.getX() + me.getX());
    } else {
        return;
    }

    if (me.getButton() == MouseEvent.BUTTON1) {
        setValue(time);
    } else if (me.getButton() == MouseEvent.BUTTON3) {
        EventMarker eventMarker = getMarkerClosestToTime(time);
        if (eventMarker != null) {
            double markerTime = Double.parseDouble(eventMarker.getProperty("timestamp"));
            setValue(markerTime);
        }
    }
}

From source file:org.gtdfree.GTDFree.java

protected TrayIcon getTrayIcon() {
    if (trayIcon == null) {
        if (ApplicationHelper.isGTKLaF()) {
            trayIcon = new TrayIcon(ApplicationHelper.loadImage(ApplicationHelper.icon_name_large_tray_splash));
        } else {//w  w w  .ja  v  a 2 s . c  o m
            trayIcon = new TrayIcon(ApplicationHelper.loadImage(ApplicationHelper.icon_name_small_tray_splash));
        }

        trayIcon.setImageAutoSize(true);
        trayIcon.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getButton() == MouseEvent.BUTTON1) {
                    trayIconPopup.setVisible(false);
                    if (getJFrame().isVisible()) {
                        getJFrame().setVisible(false);
                    } else {
                        pushVisible();
                    }
                } else {
                    if (trayIconPopup.isVisible()) {
                        trayIconPopup.setVisible(false);
                    } else {
                        Point p = new Point(e.getPoint());
                        /*
                         * Disabled, because we are anyway doing things like rollover,
                         * which are probably done by Frame.
                        if (getJFrame().isShowing()) {
                           SwingUtilities.convertPointFromScreen(p, getJFrame());
                           trayIconPopup.show(getJFrame(), p.x, p.y);
                        } else {
                        }*/
                        trayIconPopup.show(null, p.x, p.y);
                    }
                }
            }
        });
        trayIcon.setToolTip("GTD-Free - " + Messages.getString("GTDFree.Tray.desc")); //$NON-NLS-1$ //$NON-NLS-2$

        /*
         * Necessary only when popup is showing with null window. Hides popup.
         */
        MouseListener hideMe = new MouseAdapter() {
            @Override
            public void mouseExited(MouseEvent e) {
                if (e.getComponent() instanceof JMenuItem) {
                    JMenuItem jm = (JMenuItem) e.getComponent();
                    jm.getModel().setRollover(false);
                    jm.getModel().setArmed(false);
                    jm.repaint();
                }

                Point p = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), trayIconPopup);
                //System.out.println(p.x+" "+p.y+" "+trayIconPopup.getWidth()+" "+trayIconPopup.getHeight());
                if (p.x < 0 || p.x >= trayIconPopup.getWidth() || p.y < 0 || p.y >= trayIconPopup.getHeight()) {
                    trayIconPopup.setVisible(false);
                }
            }

            @Override
            public void mouseEntered(MouseEvent e) {
                if (e.getComponent() instanceof JMenuItem) {
                    JMenuItem jm = (JMenuItem) e.getComponent();
                    jm.getModel().setRollover(true);
                    jm.getModel().setArmed(true);
                    jm.repaint();
                }
            }
        };

        trayIconPopup = new JPopupMenu();
        trayIconPopup.addMouseListener(hideMe);

        JMenuItem mi = new JMenuItem(Messages.getString("GTDFree.Tray.Drop")); //$NON-NLS-1$
        mi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_small_collecting));
        mi.setToolTipText(Messages.getString("GTDFree.Tray.Drop.desc")); //$NON-NLS-1$
        mi.addMouseListener(hideMe);

        /*
         * Workaround for tray, if JFrame is showing, then mouse click is not fired
         */
        mi.addMouseListener(new MouseAdapter() {
            private boolean click = false;

            @Override
            public void mousePressed(MouseEvent e) {
                click = true;
            }

            @Override
            public void mouseReleased(MouseEvent e) {
                if (click) {
                    click = false;
                    doMouseClicked(e);
                }
            }

            @Override
            public void mouseExited(MouseEvent e) {
                click = false;
            }

            private void doMouseClicked(MouseEvent e) {
                trayIconPopup.setVisible(false);
                Clipboard c = null;
                if (e.getButton() == MouseEvent.BUTTON1) {
                    c = Toolkit.getDefaultToolkit().getSystemClipboard();
                } else if (e.getButton() == MouseEvent.BUTTON2) {
                    c = Toolkit.getDefaultToolkit().getSystemSelection();
                } else {
                    return;
                }
                try {
                    Object o = c.getData(DataFlavor.stringFlavor);
                    if (o != null) {
                        getEngine().getGTDModel().collectAction(o.toString());
                    }
                    flashMessage(Messages.getString("GTDFree.Tray.Collect.ok"), e.getLocationOnScreen()); //$NON-NLS-1$
                } catch (Exception e1) {
                    Logger.getLogger(this.getClass()).debug("Internal error.", e1); //$NON-NLS-1$
                    flashMessage(Messages.getString("GTDFree.Tray.Collect.fail") + e1.getMessage(), //$NON-NLS-1$
                            e.getLocationOnScreen());
                }
            }
        });

        TransferHandler th = new TransferHandler() {
            private static final long serialVersionUID = 1L;

            @Override
            public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) {
                return DataFlavor.selectBestTextFlavor(transferFlavors) != null;
            }

            @Override
            public boolean importData(JComponent comp, Transferable t) {
                try {
                    DataFlavor f = DataFlavor.selectBestTextFlavor(t.getTransferDataFlavors());
                    Object o = t.getTransferData(f);
                    if (o != null) {
                        getEngine().getGTDModel().collectAction(o.toString());
                    }
                    return true;
                } catch (UnsupportedFlavorException e) {
                    Logger.getLogger(this.getClass()).debug("Internal error.", e); //$NON-NLS-1$
                } catch (IOException e) {
                    Logger.getLogger(this.getClass()).debug("Internal error.", e); //$NON-NLS-1$
                }
                return false;
            }

        };
        mi.setTransferHandler(th);

        trayIconPopup.add(mi);

        mi = new JMenuItem();
        mi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_delete));
        mi.setText(Messages.getString("GTDFree.Tray.Hide")); //$NON-NLS-1$
        mi.setToolTipText(Messages.getString("GTDFree.Tray.Hide.desc")); //$NON-NLS-1$
        mi.addMouseListener(hideMe);
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                trayIconPopup.setVisible(false);
                if (getJFrame().isVisible()) {
                    getJFrame().setVisible(false);
                }
            }
        });
        trayIconPopup.add(mi);

        mi = new JMenuItem();
        mi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_small_splash));
        mi.setText(Messages.getString("GTDFree.Tray.Show")); //$NON-NLS-1$
        mi.setToolTipText(Messages.getString("GTDFree.Tray.Show.desc")); //$NON-NLS-1$
        mi.addMouseListener(hideMe);
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                trayIconPopup.setVisible(false);
                pushVisible();
            }
        });
        trayIconPopup.add(mi);

        mi = new JMenuItem();
        mi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_exit));
        mi.setText(Messages.getString("GTDFree.Tray.Exit")); //$NON-NLS-1$
        mi.addMouseListener(hideMe);
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                trayIconPopup.setVisible(false);
                close(false);
            }
        });
        trayIconPopup.add(mi);

    }
    return trayIcon;
}

From source file:pl.otros.vfs.browser.VfsBrowser.java

License:asdf

private void addOpenActionToList(final JList favoritesList) {
    favoritesList.getActionMap().put(ACTION_OPEN, new OpenSelectedFavorite(this, favoritesList));
    favoritesList.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
                favoritesList.getActionMap().get(ACTION_OPEN).actionPerformed(null);
            }/*from   w  w  w  .j  a v  a  2  s .c  om*/
        }
    });
    InputMap favoritesListInputMap = favoritesList.getInputMap(JComponent.WHEN_FOCUSED);
    favoritesListInputMap.put(KeyStroke.getKeyStroke("ENTER"), ACTION_OPEN);
}

From source file:net.ytbolg.mcxa.MCLaucherXA.java

private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
    //    GameInfo.uuid = UUID.randomUUID().toString().toUpperCase().replace("-", "");
    //     GameInfo.rb.getBundle(tpf)

    //        jMenu3.setVisible(false);
    setTitle(MainTitle);//from  w w w  . java 2s.c  om
    jLabel2.setText(Lang.getLang("Main_Label_Username"));
    jCheckBox1.setText(Lang.getLang("Main_CheckBox_zhangben"));
    jLabel4.setText(Lang.getLang("Main_Label_Memory"));
    jLabel1.setText(Lang.getLang("Main_Label_Type"));
    jLabel3.setText(Lang.getLang("Main_Label_Time"));
    jLabel6.setText(Lang.getLang("Main_Label_BMCLVAPI"));
    jButton1.setText(Lang.getLang("Main_Button_Lauch"));
    //  jButton2.setText(Lang.getLang("Main_Button_GetAss"));
    jMenu1.setText(Lang.getLang("Main_Menu_File"));
    jMenu2.setText(Lang.getLang("Main_Menu_Help"));
    jMenuItem1.setText(Lang.getLang("Main_Menu_DownVersion"));
    jMenuItem3.setText(Lang.getLang("Main_Menu_DownForge"));
    jMenuItem2.setText(Lang.getLang("Main_Menu_Config"));
    jMenuItem4.setText(Lang.getLang("Main_Menu_Update"));
    //  jMenuItem4.setText(Lang.getLang("Main_Menu_Delete"));
    jLabel7.setText(Lang.getLang("Main_Label_Update"));
    jLabel9.setText(Lang.getLang("Main_Label_AppArgs"));
    jLabel7.setVisible(Updater.NeedUpdate());
    JMenuItem ji = jPopupMenu1.add(Lang.getLang("Main_Menu_Delete"));
    JMenuItem j2 = jPopupMenu1.add(Lang.getLang("Main_Menu_Brush"));
    JMenuItem j3 = jPopupMenu1.add(Lang.getLang("Main_Button_GetAss"));
    JMenuItem j4 = jPopupMenu1.add(Lang.getLang("Main_Menu_RedownloadLib"));

    j2.addMouseListener(new MouseListener() {

        @Override
        public void mouseClicked(MouseEvent e) {

            //  throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mousePressed(MouseEvent e) {
            jList1.setListData(GameInfoGet.getGameVersions());
            //   throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            //  throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseEntered(MouseEvent e) {
            //     throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseExited(MouseEvent e) {
            //   throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    });
    ji.addMouseListener(new MouseListener() {

        @Override
        public void mouseClicked(MouseEvent e) {

            //if(e.getComponent().)            
            //    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mousePressed(MouseEvent e) {
            //     System.out.println("Right click");
            if (e.getButton() == MouseEvent.BUTTON1) {
                System.out.println(
                        GameInfo.GameDir + tpf + "versions" + tpf + jList1.getSelectedValue().toString());

                deleteDir(new File(
                        GameInfo.GameDir + tpf + "versions" + tpf + jList1.getSelectedValue().toString()));
                jList1.setListData(GameInfoGet.getGameVersions());
            } //      System.out.println("Right click"); // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseEntered(MouseEvent e) {
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseExited(MouseEvent e) {
            //  throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        public void mouseDragged(MouseEvent e) {

        }
    });
    j3.addMouseListener(new MouseListener() {

        @Override
        public void mouseClicked(MouseEvent e) {

            //   throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mousePressed(MouseEvent e) {
            GameInfo.assVersion = jList1.getSelectedValue().toString();
            try {
                GetAss();
                //  throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            } catch (ParserConfigurationException ex) {
                Logger.getLogger(MCLaucherXA.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            //   throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseEntered(MouseEvent e) {
            /////   throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseExited(MouseEvent e) {
            //  throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    });
    j4.addMouseListener(new MouseListener() {

        @Override
        public void mouseClicked(MouseEvent e) {
            //    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mousePressed(MouseEvent e) {
            try {
                Downloader d = new Downloader();
                d.setUnzip(false);
                String al = GameInfoGet
                        .libstotruedir(GameInfoGet.getLibs(jList1.getSelectedValue().toString()));
                String libs[] = al.split(";");
                for (int a = 0; a < libs.length; a++) {
                    libs[a] = libs[a].substring(1, libs[a].length() - 1);
                }
                for (String lib : libs) {
                    File f = new File(lib);
                    if (f.exists()) {
                        f.delete();
                    }
                    d.add(DownLoadURL.getURL(DownLoadURL.LIBRARIES,
                            Integer.valueOf(Config.getConfig("DownSou")))
                            + lib.replaceFirst(Matcher.quoteReplacement(GameInfo.GameDir + tpf + "libraries"),
                                    ""),
                            lib);
                }
                d.setVisible(true);
                d.start();

                //   throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            } catch (IOException | JSONException ex) {
                Logger.getLogger(MCLaucherXA.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            //  throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseEntered(MouseEvent e) {
            //      throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void mouseExited(MouseEvent e) {
            //   throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    });

    //  this.setIconImage(this.getToolkit().getImage(getClass().getResource("/icon_16x16.icon")));
    //   System.out.println(p.getProperty("zhengbanmima"));
    jCheckBox1.setSelected(Config.getConfig("iszhengban").equals("true"));
    jCheckBox1ActionPerformed(null);
    setLocationRelativeTo(getOwner());
    if (!System.getProperty("os.name").contains("Windows")) {
        jLabel8.setText(Lang.getLang("Main_NotWindows"));
        //   jLabel9.setText();

    }

    this.setResizable(false);
    jList1.setListData(GameInfoGet.getGameVersions());// TODO add your handling code here:
    GameInfo.downUrl = Config.getConfig("downUrl");
    try {
        int m = GameInfoGet.getGameVersions().length;
        vs = new JSONObject[m];
        //  System.out.println(m);
        for (int i = 0; i < m; i++) {
            vs[i] = new JSONObject(ReadFile(GameInfo.GameDir + tpf + "versions" + tpf
                    + GameInfoGet.getGameVersions()[i] + tpf + GameInfoGet.getGameVersions()[i] + ".json"));
        }
        jPasswordField1.setText(Config.getConfig("zhengbanmima"));
        if (Config.getConfig("zhengbanmima").equals("")) {
            jCheckBox1.setSelected(false);
            jPasswordField1.setEnabled(false);

        }
        jTextField1.setText(Config.getConfig("username"));
        jTextField2.setText(Config.getConfig("lastmemory"));
        int i = 0;
        //     System.out.println(p.getProperty("lastgameversion"));
        i = Integer.parseInt(Config.getConfig("lastgameversion"));
        if (i < 0) {
            i = 0;
        }
        jList1.setSelectedIndex(i);
        if (jList1.getModel().getSize() != 0) {
            BrushLabels(jList1.getSelectedIndex());
        }
        //    OutputStream in = new FileOutputStream(GameInfo.Rundir + tpf + "MCXA.cfg");
        Config.Save();
        // p.store(in, "= =");
        if (MakeCmd.isChanged(
                new ZipFile(GameInfo.GameDir + tpf + "versions" + tpf + jList1.getSelectedValue().toString()
                        + tpf + jList1.getSelectedValue().toString() + ".jar"))) {
            jComboBox1.setSelectedIndex(0);
        }
    } catch (IOException | JSONException e) {
    } catch (Exception ex) {
        Logger.getLogger(MCLaucherXA.class.getName()).log(Level.SEVERE, null, ex);
    }
    // TODO add your handling code here:
}