Example usage for java.awt.event MouseEvent getPoint

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

Introduction

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

Prototype

public Point getPoint() 

Source Link

Document

Returns the x,y position of the event relative to the source component.

Usage

From source file:xtrememp.PlaylistManager.java

private void initComponents() {
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);//from w ww  . java 2  s .  c  om
    openPlaylistButton = new JButton(Utilities.DOCUMENT_OPEN_ICON);
    openPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.OpenPlaylist"));
    openPlaylistButton.addActionListener(this);
    toolBar.add(openPlaylistButton);
    savePlaylistButton = new JButton(Utilities.DOCUMENT_SAVE_ICON);
    savePlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.SavePlaylist"));
    savePlaylistButton.addActionListener(this);
    toolBar.add(savePlaylistButton);
    toolBar.addSeparator();
    addToPlaylistButton = new JButton(Utilities.LIST_ADD_ICON);
    addToPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.AddToPlaylist"));
    addToPlaylistButton.addActionListener(this);
    toolBar.add(addToPlaylistButton);
    remFromPlaylistButton = new JButton(Utilities.LIST_REMOVE_ICON);
    remFromPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.RemoveFromPlaylist"));
    remFromPlaylistButton.addActionListener(this);
    remFromPlaylistButton.setEnabled(false);
    toolBar.add(remFromPlaylistButton);
    clearPlaylistButton = new JButton(Utilities.EDIT_CLEAR_ICON);
    clearPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.ClearPlaylist"));
    clearPlaylistButton.addActionListener(this);
    clearPlaylistButton.setEnabled(false);
    toolBar.add(clearPlaylistButton);
    toolBar.addSeparator();
    moveUpButton = new JButton(Utilities.GO_UP_ICON);
    moveUpButton.setToolTipText(tr("MainFrame.PlaylistManager.MoveUp"));
    moveUpButton.addActionListener(this);
    moveUpButton.setEnabled(false);
    toolBar.add(moveUpButton);
    moveDownButton = new JButton(Utilities.GO_DOWN_ICON);
    moveDownButton.setToolTipText(tr("MainFrame.PlaylistManager.MoveDown"));
    moveDownButton.addActionListener(this);
    moveDownButton.setEnabled(false);
    toolBar.add(moveDownButton);
    toolBar.addSeparator();
    mediaInfoButton = new JButton(Utilities.MEDIA_INFO_ICON);
    mediaInfoButton.setToolTipText(tr("MainFrame.PlaylistManager.MediaInfo"));
    mediaInfoButton.addActionListener(this);
    mediaInfoButton.setEnabled(false);
    toolBar.add(mediaInfoButton);
    toolBar.add(Box.createHorizontalGlue());
    searchTextField = new SearchTextField(15);
    searchTextField.setMaximumSize(new Dimension(120, searchTextField.getPreferredSize().height));
    searchTextField.getTextField().getDocument().addDocumentListener(new SearchFilterListener());
    toolBar.add(searchTextField);
    toolBar.add(Box.createHorizontalStrut(6));
    this.add(toolBar, BorderLayout.NORTH);

    playlistTable = new JTable(playlistTableModel, playlistTableColumnModel);
    playlistTable.setDefaultRenderer(String.class, new PlaylistCellRenderer());
    playlistTable.setActionMap(null);

    playlistTable.getTableHeader().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent ev) {
            if (SwingUtilities.isRightMouseButton(ev)
                    || (MouseInfo.getNumberOfButtons() == 1 && ev.isControlDown())) {
                playlistTableColumnModel.getPopupMenu().show(playlistTable.getTableHeader(), ev.getX(),
                        ev.getY());
                return;
            }

            int clickedColumn = playlistTableColumnModel.getColumnIndexAtX(ev.getX());
            PlaylistTableColumn playlistColumn = playlistTableColumnModel.getColumn(clickedColumn);
            playlistTableColumnModel.resetAll(playlistColumn.getModelIndex());
            playlistColumn.setSortOrderUp(!playlistColumn.isSortOrderUp());
            playlistTableModel.sort(playlistColumn.getComparator());

            colorizeRow();
        }
    });
    playlistTable.setFillsViewportHeight(true);
    playlistTable.setShowGrid(false);
    playlistTable.setRowSelectionAllowed(true);
    playlistTable.setColumnSelectionAllowed(false);
    playlistTable.setDragEnabled(false);
    playlistTable.setFont(playlistTable.getFont().deriveFont(Font.BOLD));
    playlistTable.setIntercellSpacing(new Dimension(0, 0));
    playlistTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    playlistTable.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent ev) {
            int selectedRow = playlistTable.rowAtPoint(ev.getPoint());
            if (SwingUtilities.isLeftMouseButton(ev) && ev.getClickCount() == 2) {
                if (selectedRow != -1) {
                    playlist.setCursorPosition(selectedRow);
                    controlListener.acOpenAndPlay();
                }
            }
        }
    });
    playlistTable.getSelectionModel().addListSelectionListener(this);
    playlistTable.getColumnModel().getSelectionModel().addListSelectionListener(this);
    playlistTable.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            // View Media Info
            if (e.getKeyCode() == KeyEvent.VK_I && e.getModifiers() == KeyEvent.CTRL_MASK) {
                viewMediaInfo();
            } // Select all
            else if (e.getKeyCode() == KeyEvent.VK_A && e.getModifiers() == KeyEvent.CTRL_MASK) {
                playlistTable.selectAll();
            } else if (e.getKeyCode() == KeyEvent.VK_UP) {
                // Move selected track(s) up
                if (e.getModifiers() == KeyEvent.ALT_MASK) {
                    moveUp();
                } // Select previous track
                else {
                    if (playlistTable.getSelectedRow() > 0) {
                        int previousRowIndex = playlistTable.getSelectedRow() - 1;
                        playlistTable.clearSelection();
                        playlistTable.addRowSelectionInterval(previousRowIndex, previousRowIndex);
                        makeRowVisible(previousRowIndex);
                    }
                }
            } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                // Move selected track(s) down
                if (e.getModifiers() == KeyEvent.ALT_MASK) {
                    moveDown();
                } // Select next track
                else {
                    if (playlistTable.getSelectedRow() < playlistTable.getRowCount() - 1) {
                        int nextRowIndex = playlistTable.getSelectedRow() + 1;
                        playlistTable.clearSelection();
                        playlistTable.addRowSelectionInterval(nextRowIndex, nextRowIndex);
                        makeRowVisible(nextRowIndex);
                    }
                }
            } // Play selected track
            else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                int selectedRow = playlistTable.getSelectedRow();
                if (selectedRow != -1) {
                    playlist.setCursorPosition(selectedRow);
                    controlListener.acOpenAndPlay();
                }
            } // Add new tracks
            else if (e.getKeyCode() == KeyEvent.VK_INSERT) {
                addFilesDialog(false);
            } // Delete selected tracks
            else if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                remove();
            }
        }
    });
    XtremeMP.getInstance().getMainFrame().setDropTarget(new DropTarget(playlistTable, this));
    JScrollPane ptScrollPane = new JScrollPane(playlistTable);
    ptScrollPane.setActionMap(null);
    this.add(ptScrollPane, BorderLayout.CENTER);
}

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

private void songData_TableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_songData_TableMouseClicked
        try {/* w w  w . java  2  s  . c o m*/
            if (evt.getClickCount() == 2 | next == 1 | previous == 1 && SwingUtilities.isLeftMouseButton(evt)) {
                currentSongRow = songData_Table.getSelectedRow();
                songLocation = songData[currentSongRow];
                sd.addToRecent(songLocation);
                for (ObjectBean list1 : list) {
                    list1.getMpg().addJmenuItemsToRecentSongs();
                }
                songPlay();
            } else if (SwingUtilities.isRightMouseButton(evt)) {
                Point point = evt.getPoint();
                int alreadySelectedRow = songData_Table.getSelectedRow();
                int currentRow = songData_Table.rowAtPoint(point);
                songData_Table.setRowSelectionInterval(alreadySelectedRow, currentRow);
                if (songData_Table.isRowSelected(currentRow)) {
                    songTable_PopUp.show(songData_Table, evt.getX(), evt.getY());
                } else {
                    songTable_PopUp.show(songTable_PopUp, evt.getX(), evt.getY());
                }
            }
        } catch (Exception e) {
            currentSongRow = songData_Table.getSelectedRow();
            songLocation = songData[currentSongRow];
            sd.addToRecent(songLocation);
            for (ObjectBean list1 : list) {
                list1.getMpg().addJmenuItemsToRecentSongs();
            }
            songPlay();
        }
        ;
    }

From source file:corelyzer.ui.CorelyzerApp.java

public void mousePressed(final MouseEvent e) {
    // From JDK Doc
    // Note: Popup menus are triggered differently on different systems.
    // Therefore, isPopupTrigger should be checked in both mousePressed and
    // mouseReleased for proper cross-platform functionality.

    Point p = e.getPoint();
    Object actionSource = e.getSource();

    if (actionSource instanceof JList) {
        // find the index of the clicked item in the JList
        int index = ((JList) e.getSource()).locationToIndex(e.getPoint());
        if (index < 0) {
            return;
        }/* www. j ava2s.com*/

        // show our popup menu if it was a right/ctrl-click
        if (e.isPopupTrigger()) {
            if (actionSource.equals(sessionList)) {
                Session s = (Session) sessionList.getSelectedValue();
                JMenuItem t;

                // Show label switching
                if (s == null) {
                    return;
                }

                String l = s.isShow() ? "Hide" : "Show";
                t = (JMenuItem) sessionPopupMenu.getComponent(0);
                t.setText(l);

                sessionPopupMenu.show(e.getComponent(), p.x, p.y);
            } else if (actionSource.equals(trackList)) {
                ((JList) e.getSource()).setSelectedIndex(index);

                // Update context-aware show/hide
                TrackSceneNode t = (TrackSceneNode) trackList.getSelectedValue();
                if ((t != null) && (t.getId() >= 0)) {
                    boolean isShown = SceneGraph.getTrackShow(t.getId());
                    String label = isShown ? "Hide" : "Show";
                    ((JMenuItem) trackPopupMenu.getComponent(0)).setText(label);
                }

                trackPopupMenu.show(e.getComponent(), p.x, p.y);
            } else if (actionSource.equals(sectionList)) {
                int[] rows = getSectionList().getSelectedIndices();

                JPopupMenu menu = sectionListPopupMenu(rows);
                menu.show(e.getComponent(), p.x, p.y);
            } else if (actionSource.equals(dataFileList)) {
                ((JList) e.getSource()).setSelectedIndex(index);
                dataPopupMenu.show(e.getComponent(), p.x, p.y);
            }
        }
    }
}

From source file:corelyzer.ui.CorelyzerApp.java

public void mouseReleased(final MouseEvent e) {
    // From JDK Doc
    // Note: Popup menus are triggered differently on different systems.
    // Therefore, isPopupTrigger should be checked in both mousePressed and
    // mouseReleased for proper cross-platform functionality.

    Point p = e.getPoint();
    Object actionSource = e.getSource();

    if (actionSource instanceof JList) {
        // find the index of the clicked item in the JList
        int index = ((JList) e.getSource()).locationToIndex(e.getPoint());
        if (index < 0) {
            return;
        }//from   w  ww.j a  va 2  s.c o m

        // show our popup menu if it was a right/ctrl-click
        if (e.isPopupTrigger()) {
            if (actionSource.equals(sessionList)) {
                Session s = (Session) sessionList.getSelectedValue();
                JMenuItem t;

                // Show label switching
                if (s == null) {
                    return;
                }

                String l = s.isShow() ? "Hide" : "Show";
                t = (JMenuItem) sessionPopupMenu.getComponent(0);
                t.setText(l);

                sessionPopupMenu.show(e.getComponent(), p.x, p.y);
            } else if (actionSource.equals(trackList)) {
                ((JList) e.getSource()).setSelectedIndex(index);

                // Update context-aware show/hide
                TrackSceneNode t = (TrackSceneNode) trackList.getSelectedValue();
                if ((t != null) && (t.getId() >= 0)) {
                    boolean isShown = SceneGraph.getTrackShow(t.getId());
                    String label = isShown ? "Hide" : "Show";
                    ((JMenuItem) trackPopupMenu.getComponent(0)).setText(label);
                }

                trackPopupMenu.show(e.getComponent(), p.x, p.y);
            } else if (actionSource.equals(sectionList)) {
                int[] rows = getSectionList().getSelectedIndices();

                JPopupMenu menu = sectionListPopupMenu(rows);
                menu.show(e.getComponent(), p.x, p.y);
            } else if (actionSource.equals(dataFileList)) {
                ((JList) e.getSource()).setSelectedIndex(index);
                dataPopupMenu.show(e.getComponent(), p.x, p.y);
            }
        }
    }
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.browser.BrowserUI.java

/**
 * Handles the mouse moved event. Displays the properties of the
 * the nodes the mouse is over./*from   w  ww .j av  a  2  s.co m*/
 * 
 * @param e   The mouse event to handle.
 */
private void rollOver(MouseEvent e) {
    if (!model.getParentModel().isRollOver())
        return;
    JTree tree = treeDisplay;
    TreePath path = treeDisplay.getClosestPathForLocation(e.getX(), e.getY());
    Rectangle bounds = tree.getPathBounds(path);
    if (!bounds.contains(e.getPoint()))
        return;
    TreeImageDisplay node = (TreeImageDisplay) path.getLastPathComponent();
    Object uo = node.getUserObject();
    if (!(uo instanceof DataObject))
        return;
}

From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.link_and_brush.LinkAndBrushChartPanel.java

@Override
public void mouseDragged(MouseEvent e) {
    // when not allowed to zoom / select, return
    if (blockSelectionOrZoom) {
        return;/*from  ww  w. j a  v  a 2s. co  m*/
    }
    // if the popup menu has already been triggered, then ignore dragging...
    if (getChartFieldValueByName("popup") != null
            && ((JPopupMenu) getChartFieldValueByName("popup")).isShowing()) {
        return;
    }

    // handle panning if we have a start point
    if (getChartFieldValueByName("panLast") != null) {
        double dx = e.getX() - ((Point) getChartFieldValueByName("panLast")).getX();
        double dy = e.getY() - ((Point) getChartFieldValueByName("panLast")).getY();
        if (dx == 0.0 && dy == 0.0) {
            return;
        }
        double wPercent = -dx / ((Double) getChartFieldValueByName("panW"));
        double hPercent = dy / ((Double) getChartFieldValueByName("panH"));
        boolean old = getChart().getPlot().isNotify();
        getChart().getPlot().setNotify(false);
        Pannable p = (Pannable) getChart().getPlot();
        if (p.getOrientation() == PlotOrientation.VERTICAL) {
            p.panDomainAxes(wPercent, getChartRenderingInfo().getPlotInfo(),
                    (Point) getChartFieldValueByName("panLast"));
            p.panRangeAxes(hPercent, getChartRenderingInfo().getPlotInfo(),
                    (Point) getChartFieldValueByName("panLast"));
        } else {
            p.panDomainAxes(hPercent, getChartRenderingInfo().getPlotInfo(),
                    (Point) getChartFieldValueByName("panLast"));
            p.panRangeAxes(wPercent, getChartRenderingInfo().getPlotInfo(),
                    (Point) getChartFieldValueByName("panLast"));
        }
        setChartFieldValue((getChartFieldByName("panLast")), e.getPoint());
        getChart().getPlot().setNotify(old);
        return;
    }

    // if no initial zoom point was set, ignore dragging...
    if (getChartFieldValueByName("zoomPoint") == null) {
        return;
    }
    Graphics2D g2 = (Graphics2D) getGraphics();

    // erase the previous zoom rectangle (if any). We only need to do
    // this is we are using XOR mode, which we do when we're not using
    // the buffer (if there is a buffer, then at the end of this method we
    // just trigger a repaint)
    if (!(Boolean) getChartFieldValueByName("useBuffer")) {
        drawZoomRectangle(g2, true);
    }

    boolean hZoom = false;
    boolean vZoom = false;
    if ((PlotOrientation) getChartFieldValueByName("orientation") == PlotOrientation.HORIZONTAL) {
        hZoom = (Boolean) getChartFieldValueByName("rangeZoomable");
        vZoom = (Boolean) getChartFieldValueByName("domainZoomable");
    } else {
        hZoom = (Boolean) getChartFieldValueByName("domainZoomable");
        vZoom = (Boolean) getChartFieldValueByName("rangeZoomable");
    }
    Point2D zoomPoint = (Point2D) getChartFieldValueByName("zoomPoint");
    Rectangle2D scaledDataArea = getScreenDataArea((int) zoomPoint.getX(), (int) zoomPoint.getY());
    if (hZoom && vZoom) {
        // selected rectangle shouldn't extend outside the data area...
        double xmax = Math.min(e.getX(), scaledDataArea.getMaxX());
        double ymax = Math.min(e.getY(), scaledDataArea.getMaxY());
        setChartFieldValue(getChartFieldByName("zoomRectangle"), new Rectangle2D.Double(zoomPoint.getX(),
                zoomPoint.getY(), xmax - zoomPoint.getX(), ymax - zoomPoint.getY()));
    } else if (hZoom) {
        double xmax = Math.min(e.getX(), scaledDataArea.getMaxX());
        setChartFieldValue(getChartFieldByName("zoomRectangle"), new Rectangle2D.Double(zoomPoint.getX(),
                scaledDataArea.getMinY(), xmax - zoomPoint.getX(), scaledDataArea.getHeight()));
    } else if (vZoom) {
        double ymax = Math.min(e.getY(), scaledDataArea.getMaxY());
        setChartFieldValue(getChartFieldByName("zoomRectangle"),
                new Rectangle2D.Double(scaledDataArea.getMinX(), zoomPoint.getY(), scaledDataArea.getWidth(),
                        ymax - zoomPoint.getY()));
    }

    // Draw the new zoom rectangle...
    if ((Boolean) getChartFieldValueByName("useBuffer")) {
        repaint();
    } else {
        // with no buffer, we use XOR to draw the rectangle "over" the
        // chart...
        drawZoomRectangle(g2, true);
    }
    g2.dispose();

}

From source file:org.gumtree.vis.plot1d.Plot1DPanel.java

/**
 * Receives notification of mouse clicks on the panel. These are
 * translated and passed on to any registered {@link ChartMouseListener}s.
 *
 * @param event  Information about the mouse event.
 */// w  w  w .j av  a 2 s  .co  m
@Override
public void mouseClicked(MouseEvent event) {

    Insets insets = getInsets();
    int x = (int) ((event.getX() - insets.left) / getScaleX());
    int y = (int) ((event.getY() - insets.top) / getScaleY());

    setAnchor(new Point2D.Double(x, y));
    if (getChart() == null) {
        return;
    }
    //        getChart().setNotify(true);  // force a redraw
    // new entity code...
    //        if (listeners.length == 0) {
    //            return;
    //        }

    //        if ((event.getModifiers() & maskingSelectionMask) != 0) {
    if (isInternalLegendEnabled) {
        Rectangle2D screenArea = getScreenDataArea();
        Rectangle2D legendArea = new Rectangle2D.Double(screenArea.getMaxX() - internalLegendSetup.getMinX(),
                screenArea.getMinY() + internalLegendSetup.getMinY(), internalLegendSetup.getWidth(),
                internalLegendSetup.getHeight());
        if (legendArea.contains(event.getPoint())) {
            selectInternalLegend(true);
            selectMask(Double.NaN, Double.NaN);
            repaint();
            return;
        } else {
            selectInternalLegend(false);
        }
    }
    if (!isTextInputEnabled() && (event.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {
        selectMask(ChartMaskingUtilities.translateScreenX(x, getScreenDataArea(), getChart()), Double.NaN);
        repaint();
    }
    if ((event.getModifiers() & seriesSelectionEventMask) == 0) {
        if (getSelectedMask() != null && (event.getModifiers() & MouseEvent.BUTTON1_MASK) != 0
                && !getSelectedMask().getRange()
                        .contains(ChartMaskingUtilities.translateScreenX(x, getScreenDataArea(), getChart()))) {
            selectMask(Double.NaN, Double.NaN);
        }
        repaint();
    } else if (!isTextInputEnabled()) {
        selectMask(ChartMaskingUtilities.translateScreenX(x, getScreenDataArea(), getChart()), Double.NaN);
        repaint();
    }

    ChartEntity entity = null;
    if (getChartRenderingInfo() != null) {
        EntityCollection entities = getChartRenderingInfo().getEntityCollection();
        if (entities != null) {
            entity = entities.getEntity(x, y);
            if (entity instanceof XYItemEntity) {
                XYItemEntity xyEntity = (XYItemEntity) entity;
                //                   XYDataset dataset = xyEntity.getDataset();
                //                   int item = ((XYItemEntity) entity).getItem();
                //                   chartX = dataset.getXValue(xyEntity.getSeriesIndex(), item);
                //                   chartY = dataset.getYValue(xyEntity.getSeriesIndex(), item);
                //                   Point2D screenPoint = ChartMaskingUtilities.translateChartPoint(
                //                         new Point2D.Double(chartX, chartY), getScreenDataArea(), getChart());
                //                   if (getHorizontalAxisTrace()) {
                //                      horizontalTraceLocation = (int) screenPoint.getX();
                //                   }
                //                   if (getVerticalAxisTrace()) {
                //                      verticalTraceLocation = (int) screenPoint.getY();
                //                   }
                if ((event.getModifiers() & seriesSelectionEventMask) != 0
                        && (event.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {
                    selectSeries(xyEntity.getSeriesIndex());
                    return;
                } else if ((event.getModifiers() & maskingSelectionMask) == 0
                        && (event.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {
                    if (selectedSeriesIndex != xyEntity.getSeriesIndex()) {
                        selectSeries(-1);
                        return;
                    }
                }
            } else {
                if (selectedSeriesIndex >= 0) {
                    if ((event.getModifiers() & seriesSelectionEventMask) != 0
                            && (event.getModifiers() & maskingSelectionMask) == 0
                            && (event.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {
                        selectSeries(-1);
                        return;
                    }
                }
            }
        }
    }
    XYChartMouseEvent chartEvent = new XYChartMouseEvent(getChart(), event, entity);
    chartEvent.setXY(getChartX(), getChartY());
    Object[] listeners = getListeners(ChartMouseListener.class);
    for (int i = listeners.length - 1; i >= 0; i -= 1) {
        ((ChartMouseListener) listeners[i]).chartMouseClicked(chartEvent);
    }
    super.mouseClicked(event);
}

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

private void setupASTInspector() {
    astInspector = new JFrame("AST");

    final MouseAdapter treeMouseListener = new MouseAdapter() {
        @Override//  w ww .ja  v  a  2  s  .  c  o m
        public void mouseMoved(MouseEvent e) {
            String text = null;
            TreePath path = astTree.getClosestPathForLocation(e.getX(), e.getY());

            if (path != null) {
                ASTNode node = (ASTNode) path.getLastPathComponent();
                if (node instanceof InstructionNode) { // TODO: debug code, remove when done
                    text = null;
                }
                try {
                    text = getCurrentCompilationUnit().getSource(node.getTextRegion());
                } catch (Exception ex) {
                    text = "Node " + node.getClass().getSimpleName() + " has invalid text region "
                            + node.getTextRegion();
                }
                text = "<HTML>" + text.replace("\n", "<BR>") + "</HTML>";
            }
            if (!ObjectUtils.equals(astTree.getToolTipText(), text)) {
                astTree.setToolTipText(text);
            }
        }
    };
    astTree.addMouseMotionListener(treeMouseListener);
    astTree.setCellRenderer(new ASTTreeCellRenderer());

    final JScrollPane pane = new JScrollPane(astTree);
    setColors(pane);
    pane.setPreferredSize(new Dimension(400, 600));

    GridBagConstraints cnstrs = constraints(0, 0, true, false, GridBagConstraints.REMAINDER);
    cnstrs.weighty = 0.9;
    panel.add(pane, cnstrs);

    // add symbol table 
    symbolTable.setFillsViewportHeight(true);
    MouseAdapter mouseListener = new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                int viewRow = symbolTable.rowAtPoint(e.getPoint());
                if (viewRow != -1) {
                    final int modelRow = symbolTable.convertRowIndexToModel(viewRow);
                    final ISymbol symbol = symbolTableModel.getSymbolForRow(modelRow);
                    final int caretPosition = symbol.getLocation().getStartingOffset();

                    IEditorView editor = null;
                    if (DefaultResourceMatcher.INSTANCE.isSame(symbol.getCompilationUnit().getResource(),
                            getSourceFromMemory())) {
                        editor = SourceEditorView.this;
                    } else if (getViewContainer() instanceof EditorContainer) {
                        final EditorContainer parent = (EditorContainer) getViewContainer();
                        try {
                            editor = parent.openResource(workspace, getCurrentProject(),
                                    symbol.getCompilationUnit().getResource(), caretPosition);
                        } catch (IOException e1) {
                            LOG.error("mouseClicked(): Failed top open "
                                    + symbol.getCompilationUnit().getResource(), e1);
                            return;
                        }
                    }
                    if (editor instanceof SourceCodeView) {
                        ((SourceCodeView) editor).moveCursorTo(caretPosition, true);
                    }
                }
            }
        }
    };
    symbolTable.addMouseListener(mouseListener);

    final JScrollPane tablePane = new JScrollPane(symbolTable);
    setColors(tablePane);
    tablePane.setPreferredSize(new Dimension(400, 200));

    cnstrs = constraints(0, 1, true, true, GridBagConstraints.REMAINDER);
    cnstrs.weighty = 0.1;
    panel.add(pane, cnstrs);

    final JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pane, tablePane);
    setColors(split);

    // setup content pane
    astInspector.getContentPane().add(split);
    setColors(astInspector.getContentPane());
    astInspector.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    astInspector.pack();
}

From source file:org.panbox.desktop.common.gui.PanboxClientGUI.java

private void shareListMouseClicked(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_shareListMouseClicked
    if (evt.getClickCount() == 2) {
        int index = shareList.locationToIndex(evt.getPoint());
        PanboxShare share = shareModel.getElementAt(index);
        client.openShareFolder(share.getName());
    }//w  ww. ja  v  a 2s.c  o  m
}

From source file:motor.part.MainPanel.java

private void Graph_PanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Graph_PanelMouseClicked
    // TODO add your handling code here:
    Point p = evt.getPoint();
    if (evt.getClickCount() == 2) {
        Banner_Panel.setVisible(false);
        Customer_Panel.setVisible(false);
        Admin_Panel.setVisible(true);
        Deleted_Message.setVisible(false);
        Details_Error_panel.setVisible(false);
        Graph_Panel.setVisible(false);
    }//  ww  w  .j a  v  a 2  s . com
}