Example usage for javax.swing SwingUtilities isRightMouseButton

List of usage examples for javax.swing SwingUtilities isRightMouseButton

Introduction

In this page you can find the example usage for javax.swing SwingUtilities isRightMouseButton.

Prototype

public static boolean isRightMouseButton(MouseEvent anEvent) 

Source Link

Document

Returns true if the mouse event specifies the right mouse button.

Usage

From source file:net.rptools.maptool.client.ui.MapToolFrame.java

private AssetPanel createAssetPanel() {
    final AssetPanel panel = new AssetPanel("mainAssetPanel");
    panel.addImagePanelMouseListener(new MouseAdapter() {
        @Override//from   w ww .  j  a  va 2  s.  co m
        public void mouseReleased(MouseEvent e) {
            // TODO use for real popup logic
            //            if (SwingUtilities.isLeftMouseButton(e)) {
            //               if (e.getClickCount() == 2) {
            //
            //                  List<Object> idList = panel.getSelectedIds();
            //                  if (idList == null || idList.size() == 0) {
            //                     return;
            //                  }
            //
            //                  final int index = (Integer) idList.get(0);
            //                  createZone(panel.getAsset(index));
            //               }
            //            }
            if (SwingUtilities.isRightMouseButton(e) && MapTool.getPlayer().isGM()) {
                List<Object> idList = panel.getSelectedIds();
                if (idList == null || idList.size() == 0) {
                    return;
                }
                final int index = (Integer) idList.get(0);

                JPopupMenu menu = new JPopupMenu();
                menu.add(new JMenuItem(new AbstractAction() {
                    {
                        putValue(NAME, I18N.getText("action.newMap"));
                    }

                    public void actionPerformed(ActionEvent e) {
                        createZone(panel.getAsset(index));
                    }
                }));
                panel.showImagePanelPopup(menu, e.getX(), e.getY());
            }
        }

        private void createZone(Asset asset) {
            Zone zone = ZoneFactory.createZone();
            zone.setName(asset.getName());
            BufferedImage image = ImageManager.getImageAndWait(asset.getId());
            if (image.getWidth() < 200 || image.getHeight() < 200) {
                zone.setBackgroundPaint(new DrawableTexturePaint(asset));
            } else {
                zone.setMapAsset(asset.getId());
                zone.setBackgroundPaint(new DrawableColorPaint(Color.black));
            }
            MapPropertiesDialog newMapDialog = new MapPropertiesDialog(MapTool.getFrame());
            newMapDialog.setZone(zone);
            newMapDialog.setVisible(true);

            if (newMapDialog.getStatus() == MapPropertiesDialog.Status.OK) {
                MapTool.addZone(zone);
            }
        }
    });
    return panel;
}

From source file:ucar.unidata.idv.control.chart.TimeSeriesChartWrapper.java

/**
 * Handle event in chart/*from   w w w.  j  a va2s.c o m*/
 *
 * @param event The event
 *
 * @return Did we handle this event
 */
public boolean chartPanelMouseDragged(MouseEvent event) {

    if (SwingUtilities.isRightMouseButton(event)) {
        return EVENT_DONTPASSON;
    }

    closestAnnotation = null;
    //Ignore shift down drag.
    if (event.isShiftDown()) {
        return EVENT_PASSON;
    }

    if (dragging && (draggedAnnotation == null)) {
        return EVENT_PASSON;
    }
    dragging = true;
    if (draggedAnnotation == null) {
        draggedAnnotation = findClosestAnnotation(getAllAnnotations(), event.getX(), event.getY(), true,
                event.isShiftDown());
    }
    if (draggedAnnotation == null) {
        return EVENT_PASSON;
    }

    draggedAnnotation.setPosition(event);
    if (draggedAnnotation instanceof RangeFilter) {
        rangeFiltersChanged();
    }
    if ((draggedAnnotation instanceof WayPoint) || (draggedAnnotation instanceof TrackSegment)) {
        Rectangle2D r = getChartPanel().getScreenDataArea();
        if (event.getX() < r.getX()) {
            panPlot(false, 0.02);
        } else if (event.getX() > r.getX() + r.getWidth()) {
            panPlot(true, 0.02);
        }

    }

    signalChartChanged();
    try {
        setLocationPositions();
    } catch (Exception exc) {
        LogUtil.logException("Setting locations", exc);
    }
    return EVENT_DONTPASSON;

}

From source file:com.SE.myPlayer.MusicPlayerGUI.java

private void folder_Playlist_TreeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_folder_Playlist_TreeMouseClicked
        DefaultMutableTreeNode selectedNode;

        if (evt.getClickCount() == 2 && SwingUtilities.isLeftMouseButton(evt)) {
            selectedNode = (DefaultMutableTreeNode) folder_Playlist_Tree.getSelectionPath().getLastPathComponent();
            getSongTable(selectedNode.toString());
            lastOpen = selectedNode.toString();
            for (ObjectBean list1 : list) {
                if (list1.getTitle().equals("library")) {
                    list1.setLastOpen(lastOpen);
                }/*from  www .  java  2  s .c om*/
            }
        } else if (SwingUtilities.isRightMouseButton(evt)) {
            DefaultTreeModel myModel = (DefaultTreeModel) folder_Playlist_Tree.getModel();
            DefaultMutableTreeNode root = (DefaultMutableTreeNode) myModel.getRoot();

            TreeNode[] nodes = myModel.getPathToRoot(root);
            TreePath treepath = new TreePath(nodes);
            folder_Playlist_Tree.setSelectionPath(treepath);
            folder_Playlist_Tree.scrollPathToVisible(treepath);

            TreePath path = folder_Playlist_Tree.getPathForLocation(evt.getX(), evt.getY());
            folder_Playlist_Tree.setSelectionPath(path);
            folder_Playlist_Tree.scrollPathToVisible(path);
            if (!folder_Playlist_Tree.isSelectionEmpty()) {
                selectedNode = (DefaultMutableTreeNode) folder_Playlist_Tree.getSelectionPath()
                        .getLastPathComponent();
                if (!"playlist".equals(selectedNode.toString()) && !"library".equals(selectedNode.toString())) {
                    folderTree_PopUp.show(folder_Playlist_Tree, evt.getX(), evt.getY());
                }
            }
        }
    }

From source file:com.peterbochs.PeterBochsDebugger.java

private void jHexTable1MouseClicked(MouseEvent evt) {
    if (SwingUtilities.isRightMouseButton(evt)) {
        // select
        Point p = evt.getPoint();
        int rowNumber = jHexTable1.rowAtPoint(p);
        int columnNumber = jHexTable1.columnAtPoint(p);
        ListSelectionModel model = jHexTable1.getSelectionModel();
        model.setSelectionInterval(rowNumber, rowNumber);
        jHexTable1.getColumnModel().getSelectionModel().setSelectionInterval(columnNumber, columnNumber);
        // end select

        getJHexTablePopupMenu().show(evt.getComponent(), evt.getX(), evt.getY());
    }/*www.j  a  va  2  s.  com*/
}

From source file:com.peterbochs.PeterBochsDebugger.java

private void jELFTableMouseClicked(MouseEvent evt) {
    if (SwingUtilities.isRightMouseButton(evt)) {
        // select
        Point p = evt.getPoint();
        int rowNumber = elfTable.rowAtPoint(p);
        int columnNumber = elfTable.columnAtPoint(p);
        ListSelectionModel model = elfTable.getSelectionModel();
        model.setSelectionInterval(rowNumber, rowNumber);
        elfTable.getColumnModel().getSelectionModel().setSelectionInterval(columnNumber, columnNumber);
        // end select

        getJELFTablePopupMenu().show(evt.getComponent(), evt.getX(), evt.getY());
    }// w ww  .j  a  va 2  s  .  c  o m
}

From source file:com.peterbochs.PeterBochsDebugger.java

public void instructionTableMouseClicked(MouseEvent evt) {
    if (SwingUtilities.isRightMouseButton(evt)) {
        JTable jTable = (JTable) evt.getSource();

        if (jTable == instructionTable) {
            Global.clickedWhichInstructionPanel = 0;
        } else {/*from w ww  .j  ava2 s .c  om*/
            Global.clickedWhichInstructionPanel = 1;
        }

        // select
        Point p = evt.getPoint();
        int rowNumber = jTable.rowAtPoint(p);
        int columnNumber = jTable.columnAtPoint(p);
        ListSelectionModel model = jTable.getSelectionModel();
        model.setSelectionInterval(rowNumber, rowNumber);

        jTable.getColumnModel().getSelectionModel().setSelectionInterval(columnNumber, columnNumber);
        // end select

        getJInstructionPanelPopupMenu().show(evt.getComponent(), evt.getX(), evt.getY());
    }
}

From source file:com.peterbochs.PeterBochsDebugger.java

private void breakpointTableMouseClicked(MouseEvent evt) {
    if (SwingUtilities.isRightMouseButton(evt)) {
        // select
        Point p = evt.getPoint();
        int rowNumber = breakpointTable.rowAtPoint(p);
        int columnNumber = breakpointTable.columnAtPoint(p);
        ListSelectionModel model = breakpointTable.getSelectionModel();
        model.setSelectionInterval(rowNumber, rowNumber);
        breakpointTable.getColumnModel().getSelectionModel().setSelectionInterval(columnNumber, columnNumber);
        // end select

        getJBreakpointPopupMenu().show(evt.getComponent(), evt.getX(), evt.getY());
    }//  w  w  w  .  j  a va  2 s . co m
}

From source file:com.peterbochs.PeterBochsDebugger.java

private void jSearchMemoryTableMouseClicked(MouseEvent evt) {
    if (SwingUtilities.isRightMouseButton(evt)) {
        // select
        Point p = evt.getPoint();
        int rowNumber = jSearchMemoryTable.rowAtPoint(p);
        int columnNumber = jSearchMemoryTable.columnAtPoint(p);
        ListSelectionModel model = jSearchMemoryTable.getSelectionModel();
        model.setSelectionInterval(rowNumber, rowNumber);
        jSearchMemoryTable.getColumnModel().getSelectionModel().setSelectionInterval(columnNumber,
                columnNumber);/*  ww w  .j a  v  a  2  s  .c o  m*/
        // end select

        getJSearchMemoryTablePopupMenu().show(evt.getComponent(), evt.getX(), evt.getY());
    }
}

From source file:op.care.med.structure.PnlMed.java

private void treeMedMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_treeMedMousePressed
    if (product == null)
        return;//from  www.j  av a 2s. c  o  m
    if (!OPDE.getAppInfo().isAllowedTo(InternalClassACL.MANAGER, internalClassID))
        return;

    if (SwingUtilities.isRightMouseButton(evt)) {
        // Dieses Popupmenu fr den Table
        SYSTools.unregisterListeners(menu);
        menu = new JPopupMenu();
        //            JMenuItem itemdaf = new JMenuItem("Neue Darreichungsform");
        //            itemdaf.addActionListener(new java.awt.event.ActionListener() {
        //                public void actionPerformed(java.awt.event.ActionEvent evt) {
        //                    btnNeuDAF(evt);
        //                }
        //            });
        //            menu.add(itemdaf);

        if (treeMed.getRowForLocation(evt.getX(), evt.getY()) != -1
                && OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) {
            JMenuItem itemedit = null;
            JMenuItem itemUPRedit = null;
            //                JMenuItem itemnew = null;
            //                JMenuItem itempack = null;
            TreePath curPath = treeMed.getPathForLocation(evt.getX(), evt.getY());
            final DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) curPath.getLastPathComponent();
            treeMed.setSelectionPath(curPath);
            //                final ListElement le = (ListElement) dmtn.getUserObject();
            //                int nodetype = ((Integer) le.getObject()).intValue();

            if (dmtn.getUserObject() instanceof TradeForm) {
                final TradeForm tradeForm = (TradeForm) dmtn.getUserObject();
                itemedit = new JMenuItem(SYSTools.xx("misc.msg.edit"));
                itemedit.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        new DlgTradeForm(tradeForm);
                        createTree();
                    }
                });
                itemUPRedit = new JMenuItem(SYSTools.xx("upreditor.tooltip"));
                itemUPRedit.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        new DlgUPREditor(tradeForm, new Closure() {
                            @Override
                            public void execute(Object o) {
                                reload();
                            }
                        });
                    }
                });
                itemUPRedit.setEnabled(tradeForm.getDosageForm().isUPRn());
                //                    itempack = new JMenuItem("Neue Verpackung");
                //                    itempack.addActionListener(new java.awt.event.ActionListener() {
                //                        public void actionPerformed(java.awt.event.ActionEvent evt) {
                //                            MedPackage mypack = new MedPackage(tradeForm);
                //                            new DlgPack(OPDE.getMainframe(), "Neu", mypack);
                ////                            OPDE.getEMF().getCache().evict(Darreichung.class, darreichung.getID());
                //                            createTree();
                //                        }
                //                    });
            } else if (dmtn.getUserObject() instanceof MedPackage) {
                final MedPackage packung = (MedPackage) dmtn.getUserObject();
                itemedit = new JMenuItem("Bearbeiten");
                itemedit.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        new DlgPack(SYSTools.xx("misc.msg.edit"), packung);
                        createTree();
                    }
                });
            } else if (dmtn.getUserObject() instanceof MedProducts) {

                itemedit = new JMenuItem("Bearbeiten");
                itemedit.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        DlgProduct dlg = new DlgProduct(SYSTools.xx("misc.msg.edit"),
                                (MedProducts) dmtn.getUserObject());
                        product = dlg.getProduct();
                        createTree();
                    }
                });
            }

            if (itemedit != null)
                menu.add(itemedit);
            if (itemUPRedit != null)
                menu.add(itemUPRedit);
        }
        menu.show(evt.getComponent(), evt.getX(), evt.getY());
    }
}

From source file:op.care.nursingprocess.DlgNursingProcess.java

private void tblPlanungMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblPlanungMousePressed
    if (!SwingUtilities.isRightMouseButton(evt)) {
        return;/*w  w w  . j a  v  a  2s.c  o m*/
    }

    Point p = evt.getPoint();
    ListSelectionModel lsm = tblPlanung.getSelectionModel();
    int row = tblPlanung.rowAtPoint(p);
    if (lsm.isSelectionEmpty() || (lsm.getMinSelectionIndex() == lsm.getMaxSelectionIndex())) {
        lsm.setSelectionInterval(row, row);
    }

    menu = new JPopupMenu();

    /***
     *      _ _                 ____                         ____       _      _
     *     (_) |_ ___ _ __ ___ |  _ \ ___  _ __  _   _ _ __ |  _ \  ___| | ___| |_ ___
     *     | | __/ _ \ '_ ` _ \| |_) / _ \| '_ \| | | | '_ \| | | |/ _ \ |/ _ \ __/ _ \
     *     | | ||  __/ | | | | |  __/ (_) | |_) | |_| | |_) | |_| |  __/ |  __/ ||  __/
     *     |_|\__\___|_| |_| |_|_|   \___/| .__/ \__,_| .__/|____/ \___|_|\___|\__\___|
     *                                    |_|         |_|
     */
    JMenuItem itemPopupDelete = new JMenuItem(SYSTools.xx("misc.commands.delete"), SYSConst.icon22delete);
    itemPopupDelete.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            for (int row : tblPlanung.getSelectedRows()) {
                listInterventionSchedule2Remove
                        .add(((TMPlan) tblPlanung.getModel()).getInterventionSchedule(row));
                nursingProcess.getInterventionSchedule()
                        .remove(((TMPlan) tblPlanung.getModel()).getInterventionSchedule(row));
            }
            ((TMPlan) tblPlanung.getModel()).fireTableDataChanged();
        }
    });
    menu.add(itemPopupDelete);

    /***
     *      _ _                 ____                        ____       _              _       _
     *     (_) |_ ___ _ __ ___ |  _ \ ___  _ __  _   _ _ __/ ___|  ___| |__   ___  __| |_   _| | ___
     *     | | __/ _ \ '_ ` _ \| |_) / _ \| '_ \| | | | '_ \___ \ / __| '_ \ / _ \/ _` | | | | |/ _ \
     *     | | ||  __/ | | | | |  __/ (_) | |_) | |_| | |_) |__) | (__| | | |  __/ (_| | |_| | |  __/
     *     |_|\__\___|_| |_| |_|_|   \___/| .__/ \__,_| .__/____/ \___|_| |_|\___|\__,_|\__,_|_|\___|
     *                                    |_|         |_|
     */
    final JMenuItem itemPopupSchedule = new JMenuItem(SYSTools.xx("misc.commands.editsheduling"),
            SYSConst.icon22clock);
    itemPopupSchedule.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            final JidePopup popup = new JidePopup();

            /**
             * This routine uses the <b>first</b> element of the selection as the template for editing
             * the schedule. After the edit it clones this "template", removes the original
             * InterventionSchedules (copying the apropriate Intervention of every single
             * Schedule first) and finally creates new schedules and adds them to
             * the CareProcess in question.
             */
            int row = tblPlanung.getSelectedRows()[0];
            InterventionSchedule firstInterventionScheduleWillBeTemplate = ((TMPlan) tblPlanung.getModel())
                    .getInterventionSchedule(row);
            JPanel dlg = new PnlSchedule(firstInterventionScheduleWillBeTemplate, new Closure() {
                @Override
                public void execute(Object o) {
                    if (o != null) {
                        InterventionSchedule template = (InterventionSchedule) o;
                        ArrayList<InterventionSchedule> listInterventionSchedule2Add = new ArrayList();
                        for (int row : tblPlanung.getSelectedRows()) {
                            InterventionSchedule oldTermin = ((TMPlan) tblPlanung.getModel())
                                    .getInterventionSchedule(row);
                            InterventionSchedule newTermin = template.clone();
                            newTermin.setIntervention(oldTermin.getIntervention());
                            listInterventionSchedule2Remove.add(oldTermin);
                            listInterventionSchedule2Add.add(newTermin);
                        }
                        nursingProcess.getInterventionSchedule().removeAll(listInterventionSchedule2Remove);
                        nursingProcess.getInterventionSchedule().addAll(listInterventionSchedule2Add);
                        popup.hidePopup();
                        Collections.sort(nursingProcess.getInterventionSchedule());
                        ((TMPlan) tblPlanung.getModel()).fireTableDataChanged();
                    }
                }
            });

            popup.setMovable(false);
            popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS));
            popup.getContentPane().add(dlg);
            popup.setOwner(jspPlanung);
            popup.removeExcludedComponent(jspPlanung);
            popup.setDefaultFocusComponent(dlg);

            GUITools.showPopup(popup, SwingConstants.SOUTH_WEST);
        }
    });
    menu.add(itemPopupSchedule);

    menu.show(evt.getComponent(), (int) p.getX(), (int) p.getY());
}