Example usage for java.awt.event MouseEvent isPopupTrigger

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

Introduction

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

Prototype

public boolean isPopupTrigger() 

Source Link

Document

Returns whether or not this mouse event is the popup menu trigger event for the platform.

Usage

From source file:EventTestPane.java

/**
 * Display mouse events that don't involve mouse motion. The mousemods()
 * method prints modifiers, and is defined below. The other methods return
 * additional information about the mouse event. showLine() displays a line
 * of text in the window. It is defined at the end of this class, along with
 * the paintComponent() method.//from  w ww .j  a va  2  s .  c  om
 */
public void processMouseEvent(MouseEvent e) {
    String type = null;
    switch (e.getID()) {
    case MouseEvent.MOUSE_PRESSED:
        type = "MOUSE_PRESSED";
        break;
    case MouseEvent.MOUSE_RELEASED:
        type = "MOUSE_RELEASED";
        break;
    case MouseEvent.MOUSE_CLICKED:
        type = "MOUSE_CLICKED";
        break;
    case MouseEvent.MOUSE_ENTERED:
        type = "MOUSE_ENTERED";
        break;
    case MouseEvent.MOUSE_EXITED:
        type = "MOUSE_EXITED";
        break;
    }
    showLine(mousemods(e) + type + ": [" + e.getX() + "," + e.getY() + "] " + "num clicks = "
            + e.getClickCount() + (e.isPopupTrigger() ? "; is popup trigger" : ""));

    // When the mouse enters the component, request keyboard focus so
    // we can receive and respond to keyboard events
    if (e.getID() == MouseEvent.MOUSE_ENTERED)
        requestFocus();
}

From source file:Main.java

/**
 * Display mouse events that don't involve mouse motion. The mousemods()
 * method prints modifiers, and is defined below. The other methods return
 * additional information about the mouse event. showLine() displays a line
 * of text in the window. It is defined at the end of this class, along with
 * the paintComponent() method.// w  ww  .  j  a v a  2  s  .c om
 */
public void processMouseEvent(MouseEvent e) {
    String type = null;
    switch (e.getID()) {
    case MouseEvent.MOUSE_DRAGGED:
        type = "MOUSE_DRAGGED";
        break;
    case MouseEvent.MOUSE_RELEASED:
        type = "MOUSE_RELEASED";
        break;
    case MouseEvent.MOUSE_CLICKED:
        type = "MOUSE_CLICKED";
        break;
    case MouseEvent.MOUSE_ENTERED:
        type = "MOUSE_ENTERED";
        break;
    case MouseEvent.MOUSE_EXITED:
        type = "MOUSE_EXITED";
        break;
    }
    showLine(mousemods(e) + type + ": [" + e.getX() + "," + e.getY() + "] " + "num clicks = "
            + e.getClickCount() + (e.isPopupTrigger() ? "; is popup trigger" : ""));

    // When the mouse enters the component, request keyboard focus so
    // we can receive and respond to keyboard events
    if (e.getID() == MouseEvent.MOUSE_ENTERED)
        requestFocus();
}

From source file:net.sf.jabref.openoffice.StyleSelectDialog.java

private void init(String inSelection) {
    this.initSelection = inSelection;

    ButtonGroup bg = new ButtonGroup();
    bg.add(useDefaultAuthoryear);/*from   w ww  .j  a  v a 2s  .  c  om*/
    bg.add(useDefaultNumerical);
    bg.add(chooseDirectly);
    bg.add(setDirectory);
    if (Globals.prefs.getBoolean(JabRefPreferences.OO_USE_DEFAULT_AUTHORYEAR_STYLE)) {
        useDefaultAuthoryear.setSelected(true);
    } else if (Globals.prefs.getBoolean(JabRefPreferences.OO_USE_DEFAULT_NUMERICAL_STYLE)) {
        useDefaultNumerical.setSelected(true);
    } else {
        if (Globals.prefs.getBoolean(JabRefPreferences.OO_CHOOSE_STYLE_DIRECTLY)) {
            chooseDirectly.setSelected(true);
        } else {
            setDirectory.setSelected(true);
        }
    }

    directFile.setText(Globals.prefs.get(JabRefPreferences.OO_DIRECT_FILE));
    styleDir.setText(Globals.prefs.get(JabRefPreferences.OO_STYLE_DIRECTORY));
    directFile.setEditable(false);
    styleDir.setEditable(false);

    popup.add(edit);

    BrowseAction dfBrowse = BrowseAction.buildForFile(directFile, directFile);
    browseDirectFile.addActionListener(dfBrowse);

    BrowseAction sdBrowse = BrowseAction.buildForDir(styleDir, setDirectory);
    browseStyleDir.addActionListener(sdBrowse);

    showDefaultAuthoryearStyle.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            displayDefaultStyle(true);
        }
    });
    showDefaultNumericalStyle.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            displayDefaultStyle(false);
        }
    });
    // Add action listener to "Edit" menu item, which is supposed to open the style file in an external editor:
    edit.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            int i = table.getSelectedRow();
            if (i == -1) {
                return;
            }
            ExternalFileType type = ExternalFileTypes.getInstance().getExternalFileTypeByExt("jstyle");
            String link = tableModel.getElementAt(i).getFile().getPath();
            try {
                if (type == null) {
                    JabRefDesktop.openExternalFileUnknown(frame, new BibEntry(), new MetaData(), link,
                            new UnknownExternalFileType("jstyle"));
                } else {
                    JabRefDesktop.openExternalFileAnyFormat(new MetaData(), link, type);
                }
            } catch (IOException e) {
                LOGGER.warn("Problem open style file editor", e);
            }
        }
    });

    diag = new JDialog(frame, Localization.lang("Styles"), true);

    styles = new BasicEventList<>();
    EventList<OOBibStyle> sortedStyles = new SortedList<>(styles);

    // Create a preview panel for previewing styles:
    preview = new PreviewPanel(null, new MetaData(), "");
    // Use the test entry from the Preview settings tab in Preferences:
    preview.setEntry(prevEntry);

    tableModel = (DefaultEventTableModel<OOBibStyle>) GlazedListsSwing
            .eventTableModelWithThreadProxyList(sortedStyles, new StyleTableFormat());
    table = new JTable(tableModel);
    TableColumnModel cm = table.getColumnModel();
    cm.getColumn(0).setPreferredWidth(100);
    cm.getColumn(1).setPreferredWidth(200);
    cm.getColumn(2).setPreferredWidth(80);
    selectionModel = (DefaultEventSelectionModel<OOBibStyle>) GlazedListsSwing
            .eventSelectionModelWithThreadProxyList(sortedStyles);
    table.setSelectionModel(selectionModel);
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent mouseEvent) {
            if (mouseEvent.isPopupTrigger()) {
                tablePopup(mouseEvent);
            }
        }

        @Override
        public void mouseReleased(MouseEvent mouseEvent) {
            if (mouseEvent.isPopupTrigger()) {
                tablePopup(mouseEvent);
            }
        }
    });

    selectionModel.getSelected().addListEventListener(new EntrySelectionListener());

    styleDir.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent documentEvent) {
            readStyles();
            setDirectory.setSelected(true);
        }

        @Override
        public void removeUpdate(DocumentEvent documentEvent) {
            readStyles();
            setDirectory.setSelected(true);
        }

        @Override
        public void changedUpdate(DocumentEvent documentEvent) {
            readStyles();
            setDirectory.setSelected(true);
        }
    });
    directFile.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent documentEvent) {
            chooseDirectly.setSelected(true);
        }

        @Override
        public void removeUpdate(DocumentEvent documentEvent) {
            chooseDirectly.setSelected(true);
        }

        @Override
        public void changedUpdate(DocumentEvent documentEvent) {
            chooseDirectly.setSelected(true);
        }
    });

    contentPane.setTopComponent(new JScrollPane(table));
    contentPane.setBottomComponent(preview);

    readStyles();

    DefaultFormBuilder b = new DefaultFormBuilder(
            new FormLayout("fill:pref,4dlu,fill:150dlu,4dlu,fill:pref", ""));
    b.append(useDefaultAuthoryear, 3);
    b.append(showDefaultAuthoryearStyle);
    b.nextLine();
    b.append(useDefaultNumerical, 3);
    b.append(showDefaultNumericalStyle);
    b.nextLine();
    b.append(chooseDirectly);
    b.append(directFile);
    b.append(browseDirectFile);
    b.nextLine();
    b.append(setDirectory);
    b.append(styleDir);
    b.append(browseStyleDir);
    b.nextLine();
    DefaultFormBuilder b2 = new DefaultFormBuilder(
            new FormLayout("fill:1dlu:grow", "fill:pref, fill:pref, fill:270dlu:grow"));

    b2.nextLine();
    b2.append(new JLabel("<html>"
            + Localization.lang("This is the list of available styles. Select the one you want to use.")
            + "</html>"));
    b2.nextLine();
    b2.append(contentPane);
    b.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    b2.getPanel().setBorder(BorderFactory.createEmptyBorder(15, 5, 5, 5));
    diag.add(b.getPanel(), BorderLayout.NORTH);
    diag.add(b2.getPanel(), BorderLayout.CENTER);

    AbstractAction okListener = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent event) {
            if (!useDefaultAuthoryear.isSelected() && !useDefaultNumerical.isSelected()) {
                if (chooseDirectly.isSelected()) {
                    File f = new File(directFile.getText());
                    if (!f.exists()) {
                        JOptionPane.showMessageDialog(diag,
                                Localization.lang(
                                        "You must select either a valid style file, or use a default style."),
                                Localization.lang("Style selection"), JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                } else {
                    if ((table.getRowCount() == 0) || (table.getSelectedRowCount() == 0)) {
                        JOptionPane.showMessageDialog(diag,
                                Localization.lang(
                                        "You must select either a valid style file, or use a default style."),
                                Localization.lang("Style selection"), JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                }
            }
            okPressed = true;
            storeSettings();
            diag.dispose();
        }
    };
    ok.addActionListener(okListener);

    Action cancelListener = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent event) {
            diag.dispose();
        }
    };
    cancel.addActionListener(cancelListener);

    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    bb.addButton(ok);
    bb.addButton(cancel);
    bb.addGlue();
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    diag.add(bb.getPanel(), BorderLayout.SOUTH);

    ActionMap am = bb.getPanel().getActionMap();
    InputMap im = bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", cancelListener);
    im.put(KeyStroke.getKeyStroke("ENTER"), "enterOk");
    am.put("enterOk", okListener);

    diag.pack();
    diag.setLocationRelativeTo(frame);
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            contentPane.setDividerLocation(contentPane.getSize().height - 150);
        }
    });

}

From source file:net.schweerelos.parrot.ui.GraphViewComponent.java

@SuppressWarnings("serial")
private void setupRenderContext(final VisualizationViewer<NodeWrapper, NodeWrapper> vis) {
    vis.setRenderer(new ParrotGraphRenderer());
    vis.setPickSupport(new ParrotPickSupport(vis));

    RenderContext<NodeWrapper, NodeWrapper> renderContext = vis.getRenderContext();

    final PickedInfo<NodeWrapper> vertexPickInfo = vis.getPickedVertexState();
    final PickedState<NodeWrapper> edgePickInfo = vis.getPickedEdgeState();

    // hide all edge arrows except for those on outgoing edges of picked
    // nodes//from  ww  w  . ja va  2  s  . co m
    renderContext.setEdgeArrowPredicate(new Predicate<Context<Graph<NodeWrapper, NodeWrapper>, NodeWrapper>>() {
        @Override
        public boolean evaluate(Context<Graph<NodeWrapper, NodeWrapper>, NodeWrapper> context) {
            NodeWrapper edge = context.element;
            NodeWrapper source = graph.getSource(edge);
            return vertexPickInfo.isPicked(source);
        }
    });

    // make edges straight lines to collapse parallel edges
    renderContext.setEdgeShapeTransformer(new EdgeShape.Line<NodeWrapper, NodeWrapper>());

    // hide text of all edges except for outgoing edges of picked nodes
    renderContext.setEdgeLabelTransformer(new Transformer<NodeWrapper, String>() {
        @Override
        public String transform(NodeWrapper edge) {
            NodeWrapper source = graph.getSource(edge);
            NodeWrapper destination = graph.getDest(edge);
            if (vertexPickInfo.isPicked(source) && !vertexPickInfo.isPicked(destination)) {
                return edge.toString();
            } else {
                return "";
            }
        }
    });
    renderContext.setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(COLOR_EDGE_LABEL) {
        @Override
        public <E> Component getEdgeLabelRendererComponent(JComponent vv, Object value, Font font,
                boolean isSelected, E edge) {
            Component component = super.getEdgeLabelRendererComponent(vv, value, font, isSelected, edge);
            component.setForeground(COLOR_EDGE_LABEL);
            return component;
        }

    });

    // start from VertexLabelAsShapeDemo

    // this class will provide both label drawing and vertex shapes
    VertexLabelAsShapeRenderer<NodeWrapper, NodeWrapper> vlasr = new VertexLabelAsShapeRenderer<NodeWrapper, NodeWrapper>(
            renderContext);
    renderContext.setVertexShapeTransformer(vlasr);

    vis.setForeground(COLOR_NODE_TEXT);

    // customize the render context

    renderContext.setVertexLabelTransformer(new ToStringLabeller<NodeWrapper>());

    renderContext.setVertexLabelRenderer(new DefaultVertexLabelRenderer(COLOR_NODE_PICKED_TEXT) {
        @Override
        public <V> Component getVertexLabelRendererComponent(JComponent vv, Object value, Font font,
                boolean isSelected, V vertexToRender) {
            Component component = super.getVertexLabelRendererComponent(vv, value, font, isSelected,
                    vertexToRender);
            if (component instanceof JLabel) {
                JLabel label = (JLabel) component;
                // add a little bit of padding around the text
                Border originalBorder = label.getBorder();
                label.setBorder(BorderFactory.createCompoundBorder(originalBorder,
                        BorderFactory.createEmptyBorder(3, 2, 4, 2)));
            }
            // now set the colour/font too
            if (vertexToRender instanceof NodeWrapper) {
                NodeWrapper vertex = (NodeWrapper) vertexToRender;
                if (vertexPickInfo.isPicked(vertex)) {
                    component.setForeground(COLOR_NODE_PICKED_TEXT);
                } else if (vertex.isHighlighted()) {
                    component.setForeground(COLOR_NODE_HIGHLIGHTED_TEXT);
                    component.setFont(font.deriveFont(Font.BOLD));
                } else if (GraphViewHelper.hasPickedNeighbour(vertex, vertexPickInfo, graph)) {
                    component.setForeground(COLOR_NODE_WITH_PICKED_NEIGHBOUR_TEXT);
                } else if (GraphViewHelper.hasPickedAdjacentEdge(vertex, edgePickInfo, graph)) {
                    component.setForeground(COLOR_NODE_ADJACENT_EDGE_PICKED_TEXT);
                } else if (GraphViewHelper.hasHighlightedNeighbour(vertex, graph)) {
                    component.setForeground(COLOR_NODE_WITH_HIGHLIGHTED_NEIGHBOUR_TEXT);
                } else {
                    component.setForeground(COLOR_NODE_TEXT);
                }
            }

            return component;
        }
    });

    // end from VertexLabelAsShapeDemo

    vis.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);

    vis.setVertexToolTipTransformer(new Transformer<NodeWrapper, String>() {
        @Override
        public String transform(NodeWrapper vertex) {
            return vertex.getToolTipText(model);
        }
    });

    // inspired by PluggableRendererDemo
    Transformer<NodeWrapper, Paint> vertexOutline = new Transformer<NodeWrapper, Paint>() {
        @Override
        public Paint transform(NodeWrapper vertex) {
            if (vertexPickInfo.isPicked(vertex)) {
                return COLOR_NODE_PICKED_BORDER;
            } else if (vertex.isHighlighted()) {
                return COLOR_NODE_HIGHLIGHTED_BORDER;
            } else {
                if (GraphViewHelper.hasPickedAdjacentEdge(vertex, edgePickInfo, graph)) {
                    return COLOR_NODE_ADJACENT_EDGE_PICKED_BORDER;
                }
                if (GraphViewHelper.hasPickedNeighbour(vertex, vertexPickInfo, graph)) {
                    return COLOR_NODE_WITH_PICKED_NEIGHBOUR_BORDER;
                } else if (GraphViewHelper.hasHighlightedNeighbour(vertex, graph)) {
                    return COLOR_NODE_WITH_HIGHLIGHTED_NEIGHBOUR_BORDER;
                }
                // will get here only if no neighbour is picked/highlighted
                return COLOR_NODE_BORDER;
            }
        }
    };
    renderContext.setVertexDrawPaintTransformer(vertexOutline);

    Transformer<NodeWrapper, Paint> vertexBackground = new Transformer<NodeWrapper, Paint>() {
        @Override
        public Paint transform(NodeWrapper vertex) {
            if (vertexPickInfo.isPicked(vertex)) {
                return COLOR_NODE_PICKED_BG;
            } else if (vertex.isHighlighted()) {
                return COLOR_NODE_HIGHLIGHTED_BG;
            } else {
                if (GraphViewHelper.hasPickedAdjacentEdge(vertex, edgePickInfo, graph)) {
                    return COLOR_NODE_ADJACENT_EDGE_PICKED_BG;
                }
                if (GraphViewHelper.hasPickedNeighbour(vertex, vertexPickInfo, graph)) {
                    return COLOR_NODE_WITH_PICKED_NEIGHBOUR_BG;
                } else if (GraphViewHelper.hasHighlightedNeighbour(vertex, graph)) {
                    return COLOR_NODE_WITH_HIGHLIGHTED_NEIGHBOUR_BG;
                }
                return COLOR_NODE_BG;
            }
        }
    };
    renderContext.setVertexFillPaintTransformer(vertexBackground);

    Transformer<NodeWrapper, Stroke> vertexStroke = new Transformer<NodeWrapper, Stroke>() {
        @Override
        public Stroke transform(NodeWrapper vertex) {
            if (vertexPickInfo.isPicked(vertex)) {
                return STROKE_VERTEX_PICKED;
            } else if (vertex.isHighlighted()) {
                return STROKE_VERTEX_HIGHLIGHTED;
            }

            Collection<NodeWrapper> edges = graph.getInEdges(vertex);
            for (NodeWrapper edge : edges) {
                if (edgePickInfo.isPicked(edge)) {
                    return STROKE_VERTEX_INCOMING_EDGE_PICKED;
                }
            }
            edges = graph.getOutEdges(vertex);
            for (NodeWrapper edge : edges) {
                if (edgePickInfo.isPicked(edge)) {
                    return STROKE_VERTEX_OUTGOING_EDGE_PICKED;
                }
            }

            // we'll only get here if none of the cases above applies
            return STROKE_VERTEX_DEFAULT;
        }
    };
    renderContext.setVertexStrokeTransformer(vertexStroke);

    Transformer<NodeWrapper, Stroke> edgeStroke = new Transformer<NodeWrapper, Stroke>() {
        @Override
        public Stroke transform(NodeWrapper edge) {
            NodeWrapper edgeSource = graph.getSource(edge);
            if (edgePickInfo.isPicked(edge)) {
                return STROKE_EDGE_PICKED;
            } else if (vertexPickInfo.isPicked(edgeSource)) {
                return STROKE_EDGE_ADJACENT_NODE_PICKED;
            } else {
                return STROKE_EDGE_DEFAULT;
            }
        }
    };
    renderContext.setEdgeStrokeTransformer(edgeStroke);

    Transformer<NodeWrapper, Paint> edgeColor = new Transformer<NodeWrapper, Paint>() {
        @Override
        public Paint transform(NodeWrapper edge) {
            if (edgePickInfo.isPicked(edge)) {
                return COLOR_EDGE_PICKED;
            } else if (GraphViewHelper.hasPickedAdjacentVertex(edge, vertexPickInfo, graph)) {
                return COLOR_EDGE_ADJACENT_VERTEX_PICKED;
            } else if (edge.isHighlighted()) {
                return COLOR_EDGE_HIGHLIGHTED;
            } else if (GraphViewHelper.hasHighlightedAdjacentVertex(edge, graph)) {
                return COLOR_EDGE_ADJACENT_VERTEX_HIGHLIGHTED;
            } else {
                return COLOR_EDGE;
            }
        }
    };
    renderContext.setEdgeDrawPaintTransformer(edgeColor);
    // draw arrows in the same colour as edges
    renderContext.setArrowDrawPaintTransformer(edgeColor);
    renderContext.setArrowFillPaintTransformer(edgeColor);

    includePredicate = new IncludePredicate<Context<Graph<NodeWrapper, NodeWrapper>, NodeWrapper>>();
    renderContext.setEdgeIncludePredicate(includePredicate);
    renderContext.setVertexIncludePredicate(includePredicate);

    vis.setBackground(COLOR_BACKGROUND);

    mouse = new DoubleClickPickingModalGraphMouse<NodeWrapper, NodeWrapper>();
    mouse.add(new AbstractPopupGraphMousePlugin() {
        @Override
        protected void handlePopup(MouseEvent e) {
            if (!e.isPopupTrigger()) {
                return;
            }
            GraphElementAccessor<NodeWrapper, NodeWrapper> pickSupport = vis.getPickSupport();
            if (pickSupport == null) {
                return;
            }

            NodeWrapper node = pickSupport.getVertex(layout, e.getX(), e.getY());
            if (node == null) {
                node = pickSupport.getEdge(layout, e.getX(), e.getY());
            }
            if (node == null) {
                return;
            }
            popup.setNodeWrapper(node);
            popup.show(vis, e.getX(), e.getY());
        }
    });
    mouse.setDoubleClickPickingPlugin(new DoubleClickPickingPlugin() {
        @Override
        void doubleClickOccurred(MouseEvent e) {
            GraphElementAccessor<NodeWrapper, NodeWrapper> pickSupport = vis.getPickSupport();
            if (pickSupport == null) {
                return;
            }

            NodeWrapper node = pickSupport.getVertex(layout, e.getX(), e.getY());
            if (node == null) {
                return;
            }
            fireNodeSelected(node);
        }
    });
    vis.setGraphMouse(mouse);

}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopTree.java

public DesktopTree() {
    layout = new MigLayout("flowy, fill, insets 0", "", "[min!][fill]");
    panel = new JPanel(layout);

    topPanel = new JPanel(new BorderLayout());
    topPanel.setVisible(false);//from   ww w . ja  v a2  s . c  o  m
    panel.add(topPanel, "growx");

    impl = new JTree();
    treeView = new JScrollPane(impl);
    panel.add(treeView, "grow");

    impl.setRootVisible(false);
    impl.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    impl.setExpandsSelectedPaths(true);

    impl.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            showPopup(e);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            showPopup(e);
        }

        private void showPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
                // select row
                Point p = e.getPoint();
                TreePath treePath = impl.getPathForLocation(p.x, p.y);
                if (treePath != null) {
                    TreeSelectionModel model = impl.getSelectionModel();
                    model.setSelectionPath(treePath);
                }
                // show popup menu
                createPopupMenu().show(e.getComponent(), e.getX(), e.getY());
            }
        }
    });

    impl.addKeyListener(new KeyAdapter() {
        protected static final int ENTER_CODE = 10;

        @Override
        public void keyPressed(KeyEvent e) {
            if (ENTER_CODE == e.getKeyCode() && e.getComponent() == DesktopTree.this.getComponent()) {
                if (enterPressAction != null) {
                    enterPressAction.actionPerform(DesktopTree.this);
                } else {
                    handleClickAction();
                }
            }
        }
    });
}

From source file:src.gui.ItTabbedPane.java

public void mousePressed(MouseEvent mouseEvent) {// this is for Linux
    if (mouseEvent.isPopupTrigger()) {
        //selectedTabIndex = indexAtLocation(mouseEvent.getX(), mouseEvent.getY()); 

        // Only show for top row
        if (getTabPlacement() == JTabbedPane.TOP) {
            popupMenu.show(this, mouseEvent.getX(), mouseEvent.getY());
        }//ww w  . j  a v a  2 s.c o  m
    }
}

From source file:it.unibas.spicygui.vista.listener.MyMouseEventListener.java

private void dispacciaEventoDrag(Component com, MouseEvent e, Point point, boolean draggedEvent) {
    Point componentPoint = SwingUtilities.convertPoint(component, e.getPoint(), com);
    if (com != null) {
        if (com instanceof JTree) {
            TreePath treePath = ((JTree) com).getPathForLocation(componentPoint.x, componentPoint.y);
            if (treePath == null || draggedEvent) {
                component.updateUI();//from ww w. j  ava 2  s. co  m
                return;
            }
        }
        if ((!(com instanceof JScrollBar) && (tmp12 instanceof JScrollBar))) {
            jLayeredPane.moveToFront(component);
            component.updateUI();
            return;
        }

        com.dispatchEvent(new MouseEvent(component, e.getID(), e.getWhen(), e.getModifiers(), componentPoint.x,
                componentPoint.y, e.getClickCount(), e.isPopupTrigger()));
        jLayeredPane.moveToFront(component);
        component.updateUI();

    }
    jLayeredPane.moveToFront(component);
    component.updateUI();
}

From source file:src.gui.ItTabbedPane.java

public void mouseReleased(MouseEvent mouseEvent) {//this is for Windows
    if (mouseEvent.isPopupTrigger()) {
        // selectedTabIndex = indexAtLocation(mouseEvent.getX(), mouseEvent.getY()); 

        // Only show for top row
        if (getTabPlacement() == JTabbedPane.TOP) {
            popupMenu.show(this, mouseEvent.getX(), mouseEvent.getY());
        }/*w w  w . j  a va  2s  . co  m*/
    }

}

From source file:net.sf.jabref.gui.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());

    // Check if the user has clicked on an icon cell to open url or pdf.
    final String[] iconType = table.getIconTypeForColumn(col);

    // Check if the user has right-clicked. If so, open the right-click menu.
    if (e.isPopupTrigger() || (e.getButton() == MouseEvent.BUTTON3)) {
        if (iconType == null) {
            processPopupTrigger(e, row);
        } else {//from  w w  w  .  j a v a  2 s . c o  m
            showIconRightClickMenu(e, row, iconType);
        }
    }
}

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 {//www  . j  a  v a 2  s.co  m
            // show right click menu for icon columns
            showIconRightClickMenu(e, row, modelColumn);
        }
    }
}