Example usage for java.awt.event MouseEvent getButton

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

Introduction

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

Prototype

public int getButton() 

Source Link

Document

Returns which, if any, of the mouse buttons has changed state.

Usage

From source file:kolacer.Kolacer.java

private void jText_thankiezMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jText_thankiezMouseReleased
    System.out.format("%d%n", evt.getButton());
    if (evt.getButton() == java.awt.event.MouseEvent.BUTTON3) {
        nastavOznaceni();/*from  ww  w . j av  a  2s. co m*/
    }
}

From source file:edu.ku.brc.specify.tasks.subpane.ESResultsTablePanel.java

/**
 * @param e/*ww w.  j av a 2 s .co m*/
 */
protected void doDoubleClickOnRow(final MouseEvent e) {
    if (e.getClickCount() == 2 && e.getButton() == 1) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                if (propChangeListener != null) {
                    propChangeListener.propertyChange(new PropertyChangeEvent(this, "doubleClick", 2, 0));
                }

                if (serviceBtns != null) {
                    for (ServiceInfo si : serviceBtns.keySet()) {
                        if (si.isDefault()) {
                            final JButton defBtn = serviceBtns.get(si);
                            if (defBtn != null) {
                                SwingUtilities.invokeLater(new Runnable() {
                                    @Override
                                    public void run() {
                                        defBtn.doClick();
                                    }
                                });
                                break;
                            }
                        }
                    }
                }
            }
        });
    }
}

From source file:net.sf.jabref.gui.maintable.MainTableSelectionListener.java

@Override
public void mouseReleased(MouseEvent e) {
    // First find the column and row on which the user has clicked.
    final int col = table.columnAtPoint(e.getPoint());
    final int row = table.rowAtPoint(e.getPoint());

    // get the MainTableColumn which is currently visible at col
    int modelIndex = table.getColumnModel().getColumn(col).getModelIndex();
    MainTableColumn modelColumn = table.getMainTableColumn(modelIndex);

    // Check if the user has right-clicked. If so, open the right-click menu.
    if (e.isPopupTrigger() || (e.getButton() == MouseEvent.BUTTON3)) {
        if ((modelColumn == null) || !modelColumn.isIconColumn()) {
            // show normal right click menu
            processPopupTrigger(e, row);
        } else {/* w  w  w. ja v a  2  s. c  o  m*/
            // show right click menu for icon columns
            showIconRightClickMenu(e, row, modelColumn);
        }
    }
}

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);
            }//  w  ww  .ja v a2 s.  c  o  m
        }
    });
    InputMap favoritesListInputMap = favoritesList.getInputMap(JComponent.WHEN_FOCUSED);
    favoritesListInputMap.put(KeyStroke.getKeyStroke("ENTER"), ACTION_OPEN);
}

From source file:com.talent.aio.examples.im.client.ui.JFrameMain.java

private void msgTextAreaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_msgTextAreaMouseClicked

    if (evt.getButton() == MouseEvent.BUTTON3) {//?
        log.error(evt.getButton() + "");
    }// w  w w  .  ja  va2 s  .  com
}

From source file:streamme.visuals.Main.java

public void loadTray() {
    if (SystemTray.isSupported()) {
        tray = SystemTray.getSystemTray();

        PopupMenu popup = new PopupMenu();
        MenuItem exitItem = new MenuItem("Exit");
        exitItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                dispose();//from   w  w  w  .  j  a v  a 2s.  co m
            }
        });

        MenuItem openItem = new MenuItem("Open");
        openItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                minimizeToTray(false);
            }
        });

        popup.add(openItem);
        popup.add(exitItem);
        trayIcon = new TrayIcon(
                Toolkit.getDefaultToolkit().getImage(getClass().getClassLoader().getResource("res/icon16.png")),
                "StreamMe", popup);
        trayIcon.setImageAutoSize(true);
        trayIcon.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent evt) {
                if (evt.getClickCount() == 2) {
                    //minimizeToTray(false);
                    return;
                }
                if (evt.getButton() == 1) {
                    minimizeToTray(!isMinimizedToTray());
                }
            }
        });

        addWindowStateListener(new WindowStateListener() {
            public void windowStateChanged(WindowEvent e) {
                if (e.getNewState() == ICONIFIED || e.getNewState() == 7) {
                    minimizeToTray(true);
                }
            }
        });

        addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                minimizeToTray(true);
            }
        });
        try {
            tray.add(trayIcon);
        } catch (AWTException ex) {
            System.out.println("Error adding icon to tray");
        }
    }
}

From source file:org.scify.talkandplay.gui.users.UserFormPanel.java

/**
 * The action listeners for the text fields and radio buttons
 *///www .j a  v  a 2 s  . co  m
private void setActionListeners() {
    selectionSensorTextField1.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent me) {
            if (selectionSensorTextField1.isEnabled()) {
                selectionSensor = new MouseSensor(me.getButton(), me.getClickCount(), "mouse");
                navigationSensor = null;
                selectionSensorTextField1.setText(setSensorText(selectionSensor));
            }
        }
    });
    selectionSensorTextField1.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent ke) {
            if (selectionSensorTextField1.isEnabled()) {
                selectionSensor = new KeyboardSensor(ke.getKeyCode(), String.valueOf(ke.getKeyChar()),
                        "keyboard");
                navigationSensor = null;
                selectionSensorTextField1.setText(setSensorText(selectionSensor));
            }
        }
    });

    navigationSensorTextField.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent me) {
            if (navigationSensorTextField.isEnabled()) {
                navigationSensor = new MouseSensor(me.getButton(), me.getClickCount(), "mouse");
                navigationSensorTextField.setText(setSensorText(navigationSensor));
            }
        }
    });
    navigationSensorTextField.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent ke) {
            if (navigationSensorTextField.isEnabled()) {
                navigationSensor = new KeyboardSensor(ke.getKeyCode(), String.valueOf(ke.getKeyChar()),
                        "keyboard");
                navigationSensorTextField.setText(setSensorText(navigationSensor));
            }
        }
    });

    selectionSensorTextField2.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent me) {
            if (selectionSensorTextField2.isEnabled()) {
                selectionSensor = new MouseSensor(me.getButton(), me.getClickCount(), "mouse");
                selectionSensorTextField2.setText(setSensorText(selectionSensor));
            }
        }
    });
    selectionSensorTextField2.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent ke) {
            if (selectionSensorTextField2.isEnabled()) {
                selectionSensor = new KeyboardSensor(ke.getKeyCode(), String.valueOf(ke.getKeyChar()),
                        "keyboard");
                selectionSensorTextField2.setText(setSensorText(selectionSensor));
            }
        }
    });

    backButton.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent me) {
            parent.changePanel(new MainPanel(parent));
        }
    });

    autoScanRadioButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (autoScanRadioButton.isSelected()) {
                disableTextField(selectionSensorTextField2);
                disableTextField(navigationSensorTextField);
                enableTextField(selectionSensorTextField1);
            }
        }
    });

    manualScanRadioButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (manualScanRadioButton.isSelected()) {
                disableTextField(selectionSensorTextField1);
                enableTextField(selectionSensorTextField2);
                enableTextField(navigationSensorTextField);
            }
        }
    });

}

From source file:org.eclipse.jubula.rc.swing.listener.RecordActions.java

/**
 * creates CAP for Click on Graphics Component
 * @param id IComponentIdentifier/*from   w  w  w  .  ja  va2s.com*/
 * @param me MouseEvent
 * @param source Component
 */
protected void clickGraphComp(IComponentIdentifier id, MouseEvent me, Component source) {
    if ((source instanceof JTable || source instanceof JList || source instanceof JTree
            || source instanceof JTabbedPane)) {
        clickInComponent(id, me, source);
    } else {
        int clickcount = me.getClickCount();
        if (clickcount < 1) {
            clickcount = 1;
        }
        String clCount = (new Integer(clickcount).toString());
        String mbutton = (new Integer(me.getButton()).toString());
        Action a = m_recordHelper.compSysToAction(id, "CompSystem.Click"); //$NON-NLS-1$
        List parValues = new LinkedList();
        parValues.add(clCount);
        parValues.add(mbutton);

        String logName = createLogicalName(source, id);

        createCAP(a, id, parValues, logName);
    }
}

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 w  w. jav a 2 s.  c  o m
        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:com.joey.software.regionSelectionToolkit.controlers.ImageProfileTool.java

@Override
public void mousePressed(MouseEvent e) {

    processMouse(e.getPoint(), e.getButton());

}