Example usage for java.awt.event MouseEvent BUTTON3

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

Introduction

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

Prototype

int BUTTON3

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

Click Source Link

Document

Indicates mouse button #3; used by #getButton .

Usage

From source file:de.tbuchloh.kiskis.gui.treeview.TreeView.java

/**
 * @param treeContext/*from  ww w .j  av  a2  s .  c o m*/
 */
public TreeView(final JPopupMenu treeContext) {
    final GroupNode root = new GroupNode();
    root.setModelNode(new Group());
    _treeModel = new DefaultTreeModel(root);
    setModel(_treeModel);

    this.setEditable(true);
    this.setCellRenderer(new SpecialNodeCellRenderer());
    this.setCellEditor(new NameCellEditor());
    this.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(final MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
                LOG.debug("Context Menu invoked!"); //$NON-NLS-1$
                treeContext.show(TreeView.this, e.getX(), e.getY());
            }
        }
    });
    setDragEnabled(true);
    setAutoscrolls(true);
}

From source file:dbseer.gui.panel.DBSeerExplainChartPanel.java

@Override
public void mouseReleased(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON3) {
        displayPopupMenu(e.getX(), e.getY());
        return;//from w w w.j a  va 2s  .  c  om
    }
    repaint();
    int smallX = Math.min(startX, endX);
    int smallY = Math.min(startY, endY);
    int bigX = Math.max(startX, endX);
    int bigY = Math.max(startY, endY);

    XYPlot plot = this.getChart().getXYPlot();
    Rectangle2D plotArea = this.getScreenDataArea();
    double chartSmallX = plot.getDomainAxis().java2DToValue(smallX, plotArea, plot.getDomainAxisEdge());
    double chartBigX = plot.getDomainAxis().java2DToValue(bigX, plotArea, plot.getDomainAxisEdge());
    double chartSmallY = plot.getRangeAxis().java2DToValue(smallY, plotArea, plot.getRangeAxisEdge());
    double chartBigY = plot.getRangeAxis().java2DToValue(bigY, plotArea, plot.getRangeAxisEdge());

    double minXValue = Math.min(chartSmallX, chartBigX);
    double maxXValue = Math.max(chartSmallX, chartBigX);
    double minYValue = Math.min(chartSmallY, chartBigY);
    double maxYValue = Math.max(chartSmallY, chartBigY);

    //testLog.append("Scanning: (" + smallX + ", " + smallY + "), (" + bigX + ", " + bigY + ")\n");
    //testLog.append("Scanning: X = [" + Math.min(chartSmallX, chartBigX) + ", " + Math.max(chartSmallX, chartBigX) + "]\n");
    //testLog.append("Scanning: Y = [" + Math.min(chartSmallY, chartBigY) + ", " + Math.max(chartSmallY, chartBigY) + "]\n");

    Set<XYItemEntity> foundItem = new HashSet<XYItemEntity>();

    XYDataset dataset = this.getChart().getXYPlot().getDataset();
    EntityCollection collection = this.getChartRenderingInfo().getEntityCollection();

    for (Object obj : collection.getEntities()) {
        if (obj instanceof XYItemEntity) {
            XYItemEntity entity = (XYItemEntity) obj;
            int series = entity.getSeriesIndex();
            int idx = entity.getItem();
            if (dataset.getX(series, idx).doubleValue() >= minXValue
                    && dataset.getX(series, idx).doubleValue() <= maxXValue
                    && dataset.getY(series, idx).doubleValue() >= minYValue
                    && dataset.getY(series, idx).doubleValue() <= maxYValue) {
                foundItem.add(entity);
            }
        }
    }

    //      for (int x = smallX; x <= bigX; ++x)
    //      {
    //         for (int y = smallY; y <= bigY; ++y)
    //         {
    //            ChartEntity entity = this.getEntityForPoint(x, y);
    //            if (entity instanceof XYItemEntity)
    //            {
    //               foundItem.add((XYItemEntity)entity);
    //            }
    //         }
    //      }

    selectedItems = foundItem;

    //      outlierRegion.clear();
    //      for (XYItemEntity entity : foundItem)
    //      {
    //         //testLog.append(entity.toString() + "\n");
    //         //testLog.append("Series = " + entity.getSeriesIndex() + ", ");
    //         //testLog.append("X = " + entity.getDataset().getX(entity.getSeriesIndex(), entity.getItem()) + ", ");
    //         //testLog.append("Y = " + entity.getDataset().getY(entity.getSeriesIndex(), entity.getItem()) + "\n");
    //         outlierRegion.add(entity.getDataset().getX(entity.getSeriesIndex(), entity.getItem()).doubleValue());
    //      }
    //
    //      Collections.sort(outlierRegion);
    //      if (!outlierRegion.isEmpty())
    //      {
    //         testLog.setText("");
    //         testLog.append("Outlier time selected = [");
    //         for (int i = 0; i < outlierRegion.size(); ++i)
    //         {
    //            testLog.append(outlierRegion.get(i).toString());
    //            if (i < outlierRegion.size() - 1)
    //            {
    //               testLog.append(" ");
    //            }
    //         }
    //         testLog.append("]\n");
    //      }
}

From source file:org.openconcerto.erp.model.FamilleArticleTree.java

public void mousePressed(MouseEvent e) {

    Object o = this.getSelectionPath().getLastPathComponent();

    int id = 1;// w ww  .j ava2  s  .  co m

    if (e.getButton() == MouseEvent.BUTTON3) {
        if (o instanceof FamilleTreeNode) {

            final FamilleTreeNode nodeSelect = (FamilleTreeNode) o;
            id = nodeSelect.getId();
        }

        final int idSelect = id;

        // Ajouter, supprimer, modifier une famille

        JPopupMenu menu = new JPopupMenu();
        menu.add(new AbstractAction("Ajouter une famille") {
            public void actionPerformed(ActionEvent e) {
                EditFrame frameAddFamille = new EditFrame(familleElt, EditFrame.CREATION);
                SQLRowValues rowVals = new SQLRowValues(familleElt.getTable());
                rowVals.put("ID_FAMILLE_ARTICLE_PERE", idSelect);
                frameAddFamille.getSQLComponent().select(rowVals);
                frameAddFamille.setVisible(true);

            }
        });

        if (idSelect > 1) {
            menu.add(new AbstractAction("Modifier") {
                public void actionPerformed(ActionEvent e) {
                    EditFrame frameModFamille = new EditFrame(familleElt, EditFrame.MODIFICATION);
                    frameModFamille.selectionId(idSelect, 1);
                    frameModFamille.setVisible(true);

                }
            });

            menu.add(new AbstractAction("Supprimer") {
                public void actionPerformed(ActionEvent e) {
                    try {
                        familleElt.archive(idSelect);
                    } catch (SQLException e1) {
                        e1.printStackTrace();
                    }
                }
            });
        }
        menu.show(e.getComponent(), e.getPoint().x, e.getPoint().y);
    }

}

From source file:gui.DownloadPanel.java

public DownloadPanel(JFrame parent, String databasePath, int connectionTimeout, int readTimeout) {
    this.parent = parent;
    setLayout(new BorderLayout());

    this.connectionTimeout = connectionTimeout;
    this.readTimeout = readTimeout;

    downloadDialogs = new ArrayList<>();

    String connectionUrl = "jdbc:sqlite:" + databasePath + File.separator + "cheetah.db";
    databaseController = new DatabaseControllerImpl("org.sqlite.JDBC", connectionUrl, 0, "", "");

    try {/* w  w  w . ja  va2s  . c o  m*/
        databaseController.createTablesIfNotExist();
    } catch (SQLException e) {
        e.printStackTrace();
    }

    // Set up Downloads table.
    downloadsTableModel = new DownloadsTableModel();
    downloadTable = new JTable(downloadsTableModel);
    popup = initPopupMenu();

    downloadTable.getSelectionModel().addListSelectionListener(e -> {
        tableSelectionChanged();
        if (downloadPanelListener != null)
            downloadPanelListener.downloadSelected(selectedDownload);
    });

    // Allow only one row at a time to be selected.
    downloadTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // Set up ProgressBar as renderer for progress column.
    ProgressRenderer renderer = new ProgressRenderer(0, 100);
    renderer.setStringPainted(true); // show progress text
    downloadTable.setDefaultRenderer(JProgressBar.class, renderer);

    // Set table's row height large enough to fit JProgressBar.
    downloadTable.setRowHeight((int) renderer.getPreferredSize().getHeight());

    downloadTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            super.mousePressed(e);
            int row = downloadTable.rowAtPoint(e.getPoint());
            downloadTable.getSelectionModel().setSelectionInterval(row, row);
            DownloadDialog downloadDialog = getDownloadDialogByDownload(selectedDownload);
            if (e.getButton() == MouseEvent.BUTTON3) { // TODO right click
                popup.show(downloadTable, e.getX(), e.getY());
            } else if (e.getClickCount() == 2) { // double click
                if (!downloadDialog.isVisible()) {
                    downloadDialog.setVisible(true);
                }
            }
        }
    });

    JScrollPane scrollPane = new JScrollPane(downloadTable);
    scrollPane.getViewport().setBackground(Color.WHITE);
    add(scrollPane, BorderLayout.CENTER);

    try {
        downloadList = databaseController.load();
    } catch (Exception e) {
        e.printStackTrace();
    }

    DownloadDialog downloadDialog;
    for (Download download : downloadList) {
        calculateDownloaded(download);
        download.setDownloadInfoListener(this);
        download.addDownloadStatusListener(this);
        downloadDialog = new DownloadDialog(parent, download);
        downloadDialog.setDownloadInfoListener(this);
        downloadDialogs.add(downloadDialog);
        downloadsTableModel.addDownload(download);
        downloadDialog.setDownloadRanges(download.getDownloadRangeList());
    }
    setColumnWidths();
}

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 .ja va 2 s .c om
    } else if (evt.getButton() == MouseEvent.BUTTON2) {
        this.reset();
    } else if (evt.getButton() == MouseEvent.BUTTON3) {
        showControlsFrame();
    }

}

From source file:org.openconcerto.erp.core.finance.accounting.element.AnalytiqueSQLElement.java

public SQLComponent createComponent() {
    return new BaseSQLComponent(this) {
        public void addViews() {
            this.setLayout(new GridBagLayout());
            final GridBagConstraints c = new DefaultGridBagConstraints();
            c.anchor = GridBagConstraints.NORTHWEST;
            c.gridwidth = 4;//  w w  w .ja  v a 2  s  .  c  o  m
            c.gridheight = 8;

            vecteurTabAxe = new Vector();

            repartitionsAxe = new Vector();
            repartitionElemsAxe = new Vector();
            postesAxe = new Vector();

            tabAxes = new JTabbedPane();

            /***********************************************************************************
             * * CREATION DES ONGLETS
             **********************************************************************************/

            // on recupere les axes existant
            // SELECT ID, NOM FROM AXE
            SQLBase base = getTable().getBase();
            SQLSelect sel = new SQLSelect(base);
            sel.addSelect(getTable().getKey());
            sel.addSelect(getTable().getField("NOM"));
            sel.addRawOrder("AXE_ANALYTIQUE.NOM");
            String req = sel.asString();

            Object ob = getTable().getBase().getDataSource().execute(req, new ArrayListHandler());

            List myList = (List) ob;
            if (myList.size() != 0) {

                // on cre les onglets et on stocke les axes
                for (int i = 0; i < myList.size(); i++) {

                    // ID, nom
                    Object[] objTmp = (Object[]) myList.get(i);

                    axes.add(new Axe(Integer.parseInt(objTmp[0].toString()), objTmp[1].toString()));

                    // on recupere les repartitions et les lements associs  l'axe
                    RepartitionAxeAnalytiquePanel repAxeComp = new RepartitionAxeAnalytiquePanel(
                            ((Axe) axes.get(i)).getId());

                    repartitionsAxe.add(repAxeComp.getRepartitions());
                    repartitionElemsAxe.add(repAxeComp.getRepartitionElems());
                    postesAxe.add(repAxeComp.getPostes());
                    tabAxes.addTab(((Axe) axes.get(i)).getNom(), repAxeComp);

                    vecteurTabAxe.add(i, new String(String.valueOf(i)));
                }

                System.out.println("Size ----> " + axes.size());
            } else {
                ajouterAxe("Nouvel Axe");
            }

            c.fill = GridBagConstraints.BOTH;
            c.weightx = 1;
            c.weighty = 1;
            this.add(tabAxes, c);

            tabAxes.addMouseListener(new MouseAdapter() {

                public void mousePressed(final MouseEvent e) {

                    final int index = tabAxes.indexAtLocation(e.getX(), e.getY());

                    validAxeText();

                    if (e.getClickCount() == 2) {

                        actionModifierAxe(e, index);
                    }

                    if (e.getButton() == MouseEvent.BUTTON3) {
                        actionDroitOnglet(index, e);
                    }
                }
            });

            tabAxes.addAncestorListener(new AncestorListener() {

                public void ancestorAdded(AncestorEvent event) {

                    validAxeText();

                }

                public void ancestorRemoved(AncestorEvent event) {

                    validAxeText();

                }

                public void ancestorMoved(AncestorEvent event) {

                    validAxeText();

                }
            });

            /***********************************************************************************
             * * AJOUT D'UN AXE
             **********************************************************************************/
            JButton boutonAddAxe = new JButton("Ajouter un axe");
            boutonAddAxe.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent arg0) {

                    if (ajoutAxeFrame == null) {
                        ajoutAxeFrame = new AjouterAxeAnalytiqueFrame(a);
                    }
                    ajoutAxeFrame.pack();
                    ajoutAxeFrame.setVisible(true);
                }
            });

            c.gridx += 4;
            c.gridwidth = 1;
            c.gridheight = 1;
            c.weightx = 0;
            c.weighty = 0;
            c.fill = GridBagConstraints.HORIZONTAL;
            this.add(boutonAddAxe, c);

            /***********************************************************************************
             * * SUPPRESSION D'UN AXE
             **********************************************************************************/
            JButton boutonDelAxe = new JButton("Supprimer un axe");
            boutonDelAxe.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent arg0) {

                    supprimerAxe(Integer.parseInt(vecteurTabAxe.get(tabAxes.getSelectedIndex()).toString()));

                }
            });

            c.gridy++;
            this.add(boutonDelAxe, c);

            JButton boutonSet = new JButton("SetVal");
            boutonSet.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent arg0) {
                    setVal();
                }
            });

            c.gridy++;
            this.add(boutonSet, c);

            JButton boutonCheck = new JButton("Check");
            boutonCheck.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent arg0) {
                    checkID();
                }
            });

            c.gridy++;
            this.add(boutonCheck, c);
        }
    };
}

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 ww  .  j a v a  2  s  .co  m
            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:org.eevolution.form.VCRPDetail.java

private void handleTreeEvent(MouseEvent e) {

    if (e.getButton() == MouseEvent.BUTTON3) {

        model.getTree().setSelectionPath(model.getTree().getPathForLocation(e.getX(), e.getY()));

        DefaultMutableTreeNode node = (DefaultMutableTreeNode) model.getTree().getSelectionPath()
                .getLastPathComponent();

        if (!(node.getUserObject() instanceof Date) && !(node.getUserObject() instanceof MPPOrderNode)) {

            popup.show(e.getComponent(), e.getX(), e.getY());
        }//from  www  .  ja  v  a  2  s  .c o  m
    }

    SwingTool.setCursorsFromChild(e.getComponent(), false);
}

From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java

public void mouseEntered(MouseEvent e) {
    if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) {

    } else {/*w w  w. j  a v a2  s.co m*/
        _cp.mouseEntered(e);
    }
}

From source file:de.tbuchloh.kiskis.gui.widgets.PasswordElement.java

private void initCreatePopup() {
    _pwdCreateMenu = new JPopupMenu();
    final JMenuItem secure = new JMenuItem(M.getString("secure_item")); //$NON-NLS-1$
    secure.addActionListener(new PasswordActionListener(PasswordFactory.SECURE));
    _pwdCreateMenu.add(secure);/*  w w  w. ja  v  a  2s.  co m*/

    final JMenuItem human = new JMenuItem(M.getString("human_readable_item")); //$NON-NLS-1$
    human.addActionListener(new PasswordActionListener(PasswordFactory.HUMAN_READABLE));
    _pwdCreateMenu.add(human);

    final JMenuItem template = new JMenuItem(M.createAction(this, "onCreateByTemplate"));
    _pwdCreateMenu.add(template);

    _specialActionsMenu = new JPopupMenu();
    _specialActionsMenu.add(M.createAction(this, "onCopyToClipboard"));

    _pwdField.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(final MouseEvent e) {
            if (e.getButton() != MouseEvent.BUTTON3) {
                return;
            }
            final int x = e.getX(); // _pwdField.getWidth()
            // - _specialActionsMenu.getWidth();
            final int y = e.getY();

            LOG.debug("Show context menu x=" + x + ", y=" + y);
            _specialActionsMenu.show(_pwdField, x, y);
        }
    });
}