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:com.haulmont.cuba.desktop.gui.components.DesktopTree.java

@Override
public void setLookupSelectHandler(Runnable selectHandler) {
    impl.addMouseListener(new MouseAdapter() {
        @Override// w  ww . j ava 2  s  . c  om
        public void mousePressed(MouseEvent e) {
            if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
                int rowForLocation = impl.getRowForLocation(e.getX(), e.getY());
                TreePath pathForLocation = impl.getPathForRow(rowForLocation);
                if (pathForLocation != null) {
                    CollectionDatasource treeCds = getDatasource();
                    if (treeCds != null) {
                        TreeModelAdapter.Node treeItem = (TreeModelAdapter.Node) pathForLocation
                                .getLastPathComponent();
                        if (treeItem != null) {
                            treeCds.setItem(treeItem.getEntity());
                            selectHandler.run();
                        }
                    }
                }
            }
        }
    });
}

From source file:org.nebulaframework.ui.swing.node.NodeMainUI.java

/**
 * Setup System Tray Icon./*w ww .jav  a 2 s  .c o m*/
 * 
 * @param frame owner frame
 */
private void setupTrayIcon(final JFrame frame) {

    idleIcon = Toolkit.getDefaultToolkit()
            .getImage(ClassLoader.getSystemResource("META-INF/resources/node_inactive.png"));

    activeIcon = Toolkit.getDefaultToolkit()
            .getImage(ClassLoader.getSystemResource("META-INF/resources/node_active.png"));

    frame.setIconImage(idleIcon);

    // If system tray is supported by OS
    if (SystemTray.isSupported()) {
        trayIcon = new TrayIcon(idleIcon, "Nebula Grid Node", createTrayPopup());
        trayIcon.setImageAutoSize(true);
        trayIcon.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getButton() == MouseEvent.BUTTON1) {
                    if (!frame.isVisible()) {
                        frame.setVisible(true);
                    }

                    frame.setExtendedState(JFrame.NORMAL);
                    frame.requestFocus();
                    frame.toFront();
                }
            }

        });

        try {
            SystemTray.getSystemTray().add(trayIcon);
        } catch (AWTException ae) {
            log.debug("[UI] Unable to Initialize Tray Icon");
            return;
        }

        frame.addWindowListener(new WindowAdapter() {

            @Override
            public void windowIconified(WindowEvent e) {
                // Hide (can be shown using tray icon)
                frame.setVisible(false);
            }

        });
    }

}

From source file:playground.sergioo.capacitiesChanger2012.gui.NetworkPanel.java

@Override
public void mouseClicked(MouseEvent e) {
    double[] p = getWorld(e.getX(), e.getY());
    if (e.getClickCount() == 2) {
        if (window.getOption().equals(Options.SELECT_LINK) && e.getButton() == MouseEvent.BUTTON1) {
            ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager().selectLink(p[0], p[1]);
            Link link = ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager()
                    .getSelectedLink();/*from w w  w  . ja v a  2  s  .  c  om*/
            try {
                link.setCapacity(
                        Double.parseDouble(JOptionPane.showInputDialog("New capacity", link.getCapacity())));
            } catch (Exception e2) {

            }
            ((SimpleSelectionNetworkPainter) getActiveLayer().getPainter()).calculateMinMax();
            window.refreshLabel(Labels.LINK);
        } else if (e.getButton() == MouseEvent.BUTTON3) {
            ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager().selectLink(p[0], p[1]);
            Link link = ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager()
                    .getSelectedLink();
            try {
                link.setFreespeed(
                        Double.parseDouble(JOptionPane.showInputDialog("New free speed", link.getFreespeed())));
            } catch (Exception e2) {

            }
            ((SimpleSelectionNetworkPainter) getActiveLayer().getPainter()).calculateMinMax();
            window.refreshLabel(Labels.LINK);
        }
    } else {
        if (window.getOption().equals(Options.SELECT_LINK) && e.getButton() == MouseEvent.BUTTON1) {
            ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager().selectLink(p[0], p[1]);
            window.refreshLabel(Labels.LINK);
        } else if (window.getOption().equals(Options.SELECT_LINK) && e.getButton() == MouseEvent.BUTTON3) {
            ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager().unselectLink();
            window.refreshLabel(Labels.LINK);
        } else if (window.getOption().equals(Options.SELECT_NODE) && e.getButton() == MouseEvent.BUTTON1) {
            ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager().selectNode(p[0], p[1]);
            window.refreshLabel(Labels.NODE);
        } else if (window.getOption().equals(Options.SELECT_NODE) && e.getButton() == MouseEvent.BUTTON3) {
            ((NetworkPainter) getActiveLayer().getPainter()).getNetworkPainterManager().unselectNode();
            window.refreshLabel(Labels.NODE);
        } else if (window.getOption().equals(Options.ZOOM) && e.getButton() == MouseEvent.BUTTON1)
            camera.zoomIn(p[0], p[1]);
        else if (window.getOption().equals(Options.ZOOM) && e.getButton() == MouseEvent.BUTTON3)
            camera.zoomOut(p[0], p[1]);
    }
    repaint();
}

From source file:it.iit.genomics.cru.igb.bundles.mi.view.MITable.java

public MITable(MITableModel model, IgbService service, final MIQuery query) {
    super(model);

    this.query = query;
    igbLogger = IGBLogger.getInstance(query.getLabel());
    this.igbService = service;

    this.SymSelectionListener = new MouseListener() {

        @SuppressWarnings("unchecked")
        @Override/*w  ww .  j  a v a 2s  . c  om*/
        public void mouseClicked(MouseEvent e) {

            if (e.getComponent().isEnabled() && e.getButton() == MouseEvent.BUTTON1) {

                if (getSelectedRow() >= 0) {
                    int modelRow = convertRowIndexToModel(getSelectedRow());

                    MIResult interaction = ((MITableModel) getModel()).getResult(modelRow);

                    structuresPanel.setCurrentInteraction(interaction);
                }

                MITable table = (MITable) e.getComponent();
                int modelRow = convertRowIndexToModel(table.getSelectedRow());
                int column = table.getSelectedColumn();

                if (e.getClickCount() == 1) {
                    if (column == MITableModel.TRACK_COLUMN) {
                        Object value = table.getValueAt(table.getSelectedRow(), column);

                        if (value instanceof JButton) {
                            MIResult result = ((MITableModel) table.getModel()).getResult(modelRow);

                            TypeContainerAnnot interactorTrack = result.createTrack();

                            igbService.addTrack(interactorTrack, interactorTrack.getID());

                            igbService.getSeqMapView().updatePanel();

                            for (TierGlyph t : igbService.getAllTierGlyphs()) {

                                if (TierGlyph.TierType.ANNOTATION.equals(t.getTierType())
                                        && (t.getAnnotStyle().getTrackName().equals(interactorTrack.getID()))) {

                                    SimpleTrackStyle style = new SimpleTrackStyle(interactorTrack.getID(),
                                            false) {

                                        @Override
                                        public boolean drawCollapseControl() {
                                            return false;
                                        }
                                    };

                                    t.getAnnotStyle().copyPropertiesFrom(style);
                                    t.getAnnotStyle().setColorProvider(new RGB());
                                    interactorTrack.setProperty(TrackLineParser.ITEM_RGB, "on");
                                }
                            }

                            igbService.getSeqMapView().updatePanel();

                            ((JButton) value).setText(interactorTrack.getID());
                            ((JButton) value).setEnabled(false);

                            updateUI();
                        }
                    }
                } else {
                    // symmetry: zoom-in
                    if (column == MITableModel.SYMS1_COLUMN) {
                        MoleculeEntry entry = ((MITableModel) table.getModel()).getResult(modelRow)
                                .getInteractor1();
                        if (query.getTaxid().equals(entry.getTaxid())) {
                            Collection<SeqSymmetry> syms = ((MITableModel) table.getModel()).getResult(modelRow)
                                    .getSymmetries1();
                            zoomToSym(syms);
                        }
                    } else if (column == MITableModel.SYMS2_COLUMN) {
                        MoleculeEntry entry = ((MITableModel) table.getModel()).getResult(modelRow)
                                .getInteractor2();
                        if (query.getTaxid().equals(entry.getTaxid())) {
                            Collection<SeqSymmetry> syms = ((MITableModel) table.getModel()).getResult(modelRow)
                                    .getSymmetries2();
                            zoomToSym(syms);
                        }
                    }

                    // Protein: link to uniprot
                    if (column == MITableModel.INTERACTOR1_COLUMN
                            || column == MITableModel.INTERACTOR2_COLUMN) {

                        MIResult miResult = ((MITableModel) table.getModel()).getResult(modelRow);

                        String id;
                        String taxid;

                        MoleculeEntry interactor;
                        if (column == MITableModel.INTERACTOR1_COLUMN) {
                            interactor = miResult.getInteractor1();
                        } else {
                            interactor = miResult.getInteractor2();
                        }

                        taxid = interactor.getTaxid();

                        String query;
                        String anchor = "";
                        switch (taxid) {
                        case MoleculeEntry.TAXID_DNA:
                        case MoleculeEntry.TAXID_RNA:
                            if (miResult.getInteractionStructures().isEmpty()) {
                                return;
                            }
                            query = "http://www.pdb.org/pdb/explore/explore.do?structureId="
                                    + miResult.getInteractionStructures().iterator().next().getStructureID();
                            break;
                        case MoleculeEntry.TAXID_LIGAND:
                            if (miResult.getInteractionStructures().isEmpty()) {
                                return;
                            }
                            query = DrugBankMapper.getInstance().isDrug(interactor.getGeneName())
                                    ? DrugBankMapper.getInstance().getDrugBankLink(interactor.getGeneName())
                                    : "http://www.ebi.ac.uk/pdbe-srv/pdbechem/chemicalCompound/show/"
                                            + interactor.getGeneName();
                            break;
                        case MoleculeEntry.TAXID_MODIFICATION:
                            query = "http://www.uniprot.org/uniprot/"
                                    + miResult.getInteractor1().getUniprotAc();
                            anchor = "#ptm_processing";
                            break;
                        default:
                            id = interactor.getUniprotAc();
                            query = "http://www.uniprot.org/uniprot/" + id;
                            break;
                        }
                        try {
                            URI uri = new URI(URIUtil.encodeQuery(query) + anchor);

                            Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
                            if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
                                desktop.browse(uri);
                            }
                        } catch (IOException ioe) {
                            JOptionPane.showMessageDialog(null, "Cannot reach Uniprot website.");
                            return;
                        } catch (URISyntaxException ue) {
                            JOptionPane.showMessageDialog(null, "Cannot reach Uniprot website: " + query);
                        }
                    }

                    // interaction type: link to psicquic
                    if (column == MITableModel.INTERACTION_TYPE_COLUMN) {

                        MIResult miResult = ((MITableModel) table.getModel()).getResult(modelRow);

                        String queryURL;
                        String idA = miResult.getInteractor1().getUniprotAc();
                        String idB = miResult.getInteractor2().getUniprotAc();

                        if (null == miResult.getPsicquicUrl()) {
                            // from the structure database
                            if (query.searchDSysMap()) {
                                queryURL = "http://http://dsysmap.irbbarcelona.org/results.php?type=proteins&neigh=2&value="
                                        + idA + "," + idB;
                            } else if (query.searchInteractome3D()) {
                                try {
                                    queryURL = "http://interactome3d.irbbarcelona.org/interaction.php?ids="
                                            + idA + ";" + idB + "&dataset="
                                            + it.iit.genomics.cru.bridges.interactome3d.ws.Utils
                                                    .getDataset(query.getTaxid());
                                } catch (Interactome3DException e3d) {
                                    // it will never happend: if the taxid was not known by 
                                    // I3D, we wouldn't have an interaction
                                    return;
                                }

                            } else {
                                return;
                            }
                        } else {

                            if (false == idA.equals(idB)) {
                                queryURL = miResult.getPsicquicUrl() + "query/id:"
                                        + miResult.getInteractor1().getUniprotAc() + "* AND id:"
                                        + miResult.getInteractor2().getUniprotAc() + "*";
                            } else {
                                queryURL = miResult.getPsicquicUrl() + "query/idA:"
                                        + miResult.getInteractor1().getUniprotAc() + "* AND idB:"
                                        + miResult.getInteractor2().getUniprotAc() + "*";
                            }
                        }
                        try {
                            URI uri = new URI(URIUtil.encodeQuery(queryURL));

                            Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
                            if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
                                desktop.browse(uri);
                            }
                        } catch (IOException ioe) {
                            JOptionPane.showMessageDialog(null, "Cannot reach psicquic server.");
                        } catch (URISyntaxException ue) {
                            JOptionPane.showMessageDialog(null, "Cannot reach psicquic server: " + queryURL);
                        }

                    }
                }
            }

        }

        @Override
        public void mousePressed(MouseEvent me) {
        }

        @Override
        public void mouseReleased(MouseEvent me) {
        }

        @Override
        public void mouseEntered(MouseEvent me) {
        }

        @Override
        public void mouseExited(MouseEvent me) {
        }
    };

    TableRowSorter<MITableModel> sorter = new MITableRowSorter(model);
    setRowSorter(sorter);

    sorter.setRowFilter(evidenceRowFilter());
    model.fireTableDataChanged();
    this.getTableHeader().setReorderingAllowed(false);

    TableCellRenderer rend = getTableHeader().getDefaultRenderer();
    TableColumnModel tcm = getColumnModel();
    for (int j = 0; j < tcm.getColumnCount(); j += 1) {
        TableColumn tc = tcm.getColumn(j);
        TableCellRenderer rendCol = tc.getHeaderRenderer(); // likely null
        if (rendCol == null) {
            rendCol = rend;
        }
        Component c = rendCol.getTableCellRendererComponent(this, tc.getHeaderValue(), false, false, 0, j);
        tc.setPreferredWidth(c.getPreferredSize().width);
    }

    TableCellRenderer buttonRenderer = new JTableButtonRenderer();

    getColumn(model.getColumnName(MITableModel.TRACK_COLUMN)).setCellRenderer(buttonRenderer);

    getColumn(model.getColumnName(MITableModel.SYMS1_COLUMN)).setCellRenderer(new GeneRenderer());
    getColumn(model.getColumnName(MITableModel.SYMS2_COLUMN)).setCellRenderer(new GeneRenderer());

    getColumn(model.getColumnName(MITableModel.INTERACTOR1_COLUMN)).setCellRenderer(new MoleculeRenderer());
    getColumn(model.getColumnName(MITableModel.INTERACTOR2_COLUMN)).setCellRenderer(new MoleculeRenderer());

    getColumn(model.getColumnName(MITableModel.INTERACTION_TYPE_COLUMN))
            .setCellRenderer(new EvidenceRenderer());

    getColumn(model.getColumnName(MITableModel.STRUCTURES_COLUMN)).setCellRenderer(new StructuresRenderer());

    setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

    int smallWidth = 75;
    int mediumWidth = 120;
    int largeWidth = 200;
    getColumnModel().getColumn(MITableModel.TRACK_COLUMN).setMinWidth(smallWidth);

    getColumnModel().getColumn(MITableModel.STRUCTURES_COLUMN).setMinWidth(smallWidth);
    getColumnModel().getColumn(MITableModel.STRUCTURES_COLUMN).setMaxWidth(smallWidth);
    getColumnModel().getColumn(MITableModel.STRUCTURES_COLUMN).setPreferredWidth(smallWidth);

    addMouseListener(SymSelectionListener);

    getSelectionModel().addListSelectionListener(new RowSelectionListener());

}

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

private JPanel createPanel() {
    treeModel = createTreeModel();/*from   w  w  w.java 2  s  . c  om*/
    tree.setModel(treeModel);
    setColors(tree);
    tree.setRootVisible(false);

    //      for (int i = 0; i < tree.getRowCount(); i++) {
    //         tree.expandRow(i);
    //      }

    tree.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                final WorkspaceTreeNode selection = getSelectedNode();
                if (selection != null) {
                    deleteResource(selection);
                }
            } else if (e.getKeyCode() == KeyEvent.VK_F5) {
                refreshWorkspace(null);
            }
        }
    });

    tree.addMouseListener(new MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
                final TreePath path = tree.getPathForLocation(e.getX(), e.getY());
                if (path != null) {
                    final WorkspaceTreeNode selected = (WorkspaceTreeNode) path.getLastPathComponent();
                    final IAssemblyProject project = getProject(selected);
                    try {
                        if (project != null) {
                            onTreeNodeLeftClick(project, selected);
                        } else {
                            System.err.println("Unable to locate project for " + selected);
                        }
                    } catch (IOException e1) {
                        LOG.error("mouseClicked(): Internal error", e1);
                    }
                }
            }
        }
    });

    final TreeSelectionListener selectionListener = new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {

        }
    };

    tree.getSelectionModel().addTreeSelectionListener(selectionListener);

    tree.setCellRenderer(new DefaultTreeCellRenderer() {

        public Color getTextSelectionColor() {
            return Color.GREEN;
        };

        public java.awt.Color getTextNonSelectionColor() {
            return Color.GREEN;
        };

        public Color getBackgroundSelectionColor() {
            return Color.BLACK;
        };

        public Color getBackgroundNonSelectionColor() {
            return Color.BLACK;
        };

        public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel,
                boolean expanded, boolean leaf, int row, boolean hasFocus) {

            java.awt.Component result = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf,
                    row, hasFocus);

            String label = value.toString();
            Color color = getTextColor();
            if (value instanceof WorkspaceTreeNode) {
                if (value instanceof ProjectNode) {
                    final ProjectNode projectNode = (ProjectNode) value;
                    final IAssemblyProject project = projectNode.getValue();
                    label = project.getName();

                    if (project.isClosed()) {
                        color = Color.LIGHT_GRAY;
                    } else {
                        if (projectNode.hasCompilationErrors()) {
                            color = Color.RED;
                        }
                    }
                } else if (value instanceof FileNode) {
                    FileNode fn = (FileNode) value;
                    label = fn.getValue().getName();
                    switch (fn.type) {
                    case DIRECTORY:
                        if (fn.hasCompilationErrors()) {
                            color = Color.RED;
                        }
                        break;
                    case OBJECT_FILE:
                        label = "[O] " + label;
                        break;
                    case EXECUTABLE:
                        label = "[E] " + label;
                        break;
                    case SOURCE_CODE:
                        label = "[S] " + label;
                        if (fn.hasCompilationErrors()) {
                            color = Color.RED;
                        }
                        break;
                    default:
                        // ok
                    }
                }
            }
            setForeground(color);
            setText(label);
            return result;
        };

    });

    setupPopupMenu();

    final JScrollPane pane = new JScrollPane(tree);
    setColors(pane);

    final JPanel result = new JPanel();
    result.setLayout(new GridBagLayout());
    GridBagConstraints cnstrs = constraints(0, 0, true, true, GridBagConstraints.BOTH);
    setColors(result);
    result.add(pane, cnstrs);
    return result;
}

From source file:org.apache.syncope.ide.netbeans.view.ResourceExplorerTopComponent.java

private void resourceExplorerTreeMouseClicked(final java.awt.event.MouseEvent evt) {
    if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 2) {
        DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) resourceExplorerTree
                .getLastSelectedPathComponent();
        DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) selectedNode.getParent();
        String parentNodeName = parentNode == null ? null : String.valueOf(parentNode.getUserObject());
        if (selectedNode.isLeaf() && StringUtils.isNotBlank(parentNodeName)) {
            String leafNodeName = (String) selectedNode.getUserObject();
            try {
                if (PluginConstants.MAIL_TEMPLATES.equals(parentNodeName)) {
                    openMailEditor(leafNodeName);
                } else if (PluginConstants.REPORT_XSLTS.equals(parentNodeName)) {
                    openReportEditor(leafNodeName);
                }//  w  w  w  .ja  v a2 s .  c om
            } catch (IOException e) {
                Exceptions.printStackTrace(e);
            }
        }
    } else if (evt.getButton() == MouseEvent.BUTTON3 && evt.getClickCount() == 1) {
        DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) resourceExplorerTree
                .getLastSelectedPathComponent();
        String selectedNodeName = (String) selectedNode.getUserObject();
        if (selectedNode.isLeaf() && !PluginConstants.ROOT_NAME.equals(selectedNodeName)
                && !PluginConstants.MAIL_TEMPLATES.equals(selectedNodeName)
                && !PluginConstants.REPORT_XSLTS.equals(selectedNodeName)) {
            leafRightClickAction(evt, selectedNode);
        } else if (PluginConstants.MAIL_TEMPLATES.equals(selectedNodeName)) {
            folderRightClickAction(evt, mailTemplates);
        } else if (PluginConstants.REPORT_XSLTS.equals(selectedNodeName)) {
            folderRightClickAction(evt, reportXslts);
        } else if (PluginConstants.ROOT_NAME.equals(selectedNodeName)) {
            rootRightClickAction(evt);
        }
    }
}

From source file:pl.edu.icm.visnow.lib.basic.viewers.Viewer2D.Display2DPanel.java

private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
    if (evt.getButton() == MouseEvent.BUTTON1) {
        tootltipActive = !tootltipActive;
        formMouseMoved(evt);/*from   ww  w.  j  a v  a2s . co  m*/
    } else if (evt.getButton() == MouseEvent.BUTTON2) {
        this.reset();
    } else if (evt.getButton() == MouseEvent.BUTTON3) {
        showControlsFrame();
    }

}

From source file:org.nebulaframework.ui.swing.cluster.ClusterMainUI.java

/**
 * System Tray Icon setup/*from  w  w w .  j av a 2  s  .  c  o  m*/
 * @param frame owner JFrame
 */
private void setupTrayIcon(final JFrame frame) {

    // Idle Icon
    idleIcon = Toolkit.getDefaultToolkit()
            .getImage(ClassLoader.getSystemResource("META-INF/resources/cluster_inactive.png"));

    // Active Icon
    activeIcon = Toolkit.getDefaultToolkit()
            .getImage(ClassLoader.getSystemResource("META-INF/resources/cluster_active.png"));

    frame.setIconImage(idleIcon);

    // If system tray is supported by OS
    if (SystemTray.isSupported()) {

        // Set Icon
        trayIcon = new TrayIcon(idleIcon, "Nebula Grid Cluster", createTrayPopup());
        trayIcon.setImageAutoSize(true);
        trayIcon.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getButton() == MouseEvent.BUTTON1) {
                    if (!frame.isVisible()) {
                        frame.setVisible(true);
                    }

                    frame.setExtendedState(JFrame.NORMAL);
                    frame.requestFocus();
                    frame.toFront();
                }
            }

        });

        try {
            SystemTray.getSystemTray().add(trayIcon);
        } catch (AWTException ae) {
            log.debug("[UI] Unable to Initialize Tray Icon");
            return;
        }

        frame.addWindowListener(new WindowAdapter() {

            @Override
            public void windowIconified(WindowEvent e) {
                // Hide (can be shown using tray icon)
                frame.setVisible(false);
            }

        });
    }

}

From source file:net.sf.mzmine.modules.visualization.neutralloss.NeutralLossPlot.java

/**
 * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
 *//*from   www .  j  av  a 2 s  .com*/
public void mouseClicked(MouseEvent event) {

    // let the parent handle the event (selection etc.)
    super.mouseClicked(event);

    // request focus to receive key events
    requestFocus();

    // if user double-clicked left button, place a request to open a
    // spectrum
    if ((event.getButton() == MouseEvent.BUTTON1) && (event.getClickCount() == 2)) {
        showSpectrumRequest = true;
    }

}

From source file:com.lfv.lanzius.application.phoneonly.PhoneOnlyView.java

public void mousePressed(MouseEvent e) {
    // Left mouse button only
    if (e.getButton() != MouseEvent.BUTTON1)
        return;//from   w  ww .j ava  2s . co  m

    eventHandler.talkButtonPressed(Constants.DEVICE_MOUSE);
    talkButtonPressed = true;
}