Example usage for java.awt.event MouseEvent getY

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

Introduction

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

Prototype

public int getY() 

Source Link

Document

Returns the vertical y position of the event relative to the source component.

Usage

From source file:edu.ku.brc.specify.tasks.RecordSetTask.java

/**
 * Adds the Context PopupMenu for the RecordSet.
 * @param roc the RolloverCommand btn to add the pop to
 *//*from www.  jav a2 s  .  c  o m*/
public void addPopMenu(final RolloverCommand roc, final boolean isOKDelete, final boolean isOKModify) {
    if (roc.getLabelText() != null) {
        final JPopupMenu popupMenu = new JPopupMenu();

        if (isOKModify) {
            JMenuItem renameMenuItem = new JMenuItem(UIRegistry.getResourceString("Rename"));
            renameMenuItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent actionEvent) {
                    roc.startEditting(RecordSetTask.this);
                }
            });
            popupMenu.add(renameMenuItem);
        }

        if (isOKDelete) {
            JMenuItem delMenuItem = new JMenuItem(UIRegistry.getResourceString("Delete"));
            delMenuItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent actionEvent) {
                    CommandDispatcher.dispatch(new CommandAction(RECORD_SET, DELETE_CMD_ACT, roc));
                }
            });
            popupMenu.add(delMenuItem);
        }

        JMenuItem viewMenuItem = new JMenuItem(UIRegistry.getResourceString("View"));
        viewMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
                CommandAction cmdAction = new CommandAction("Express_Search", "ViewRecordSet", roc);
                cmdAction.setProperty("canModify", isOKDelete);
                CommandDispatcher.dispatch(cmdAction);
            }
        });
        popupMenu.add(viewMenuItem);

        MouseListener mouseListener = new MouseAdapter() {
            private boolean showIfPopupTrigger(MouseEvent mouseEvent) {
                if (roc.isEnabled() && mouseEvent.isPopupTrigger() && popupMenu.getComponentCount() > 0) {
                    popupMenu.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
                    return true;
                }
                return false;
            }

            @Override
            public void mousePressed(MouseEvent mouseEvent) {
                if (roc.isEnabled()) {
                    showIfPopupTrigger(mouseEvent);
                }
            }

            @Override
            public void mouseReleased(MouseEvent mouseEvent) {
                if (roc.isEnabled()) {
                    showIfPopupTrigger(mouseEvent);
                }
            }
        };
        roc.addMouseListener(mouseListener);
    }
}

From source file:com.jcraft.weirdx.DDXWindowImp.java

public void mouseExited(MouseEvent e) {
    if (window == null)
        return;// w  w w.j a  va  2s.  c  o m

    if (window.id == window.screen.rootId) {
        return;
    }

    int x = e.getX() + window.x;
    int y = e.getY() + window.y;

    XWindow.sprite.hot.x = x;
    XWindow.sprite.hot.y = y;

    int mod = e.getModifiers();
    int state = 0;
    if ((mod & InputEvent.BUTTON1_MASK) != 0)
        state |= (1 << 8);
    if ((mod & InputEvent.BUTTON2_MASK) != 0)
        state |= (1 << 9);
    if ((mod & InputEvent.BUTTON3_MASK) != 0)
        state |= (1 << 10);
    if ((mod & InputEvent.SHIFT_MASK) != 0)
        state |= 1;
    if ((mod & InputEvent.CTRL_MASK) != 0)
        state |= 4;
    // alt -> state|=8;
    Client client = window.client;
    if (client == null || client == serverClient)
        return;

    event.mkLeaveNotify(0, // Ancestor
            window.screen.rootId, window.id, 0, x, y, e.getX(), e.getY(), state, 0, // Normal
            0x1 | 0x02 // focus|same-screen
    );
    try {
        XWindow.sendDeviceEvent(window, event, XWindow.grab, null, 1);
    } catch (Exception ee) {
    }
}

From source file:com.mirth.connect.client.ui.browsers.event.EventBrowser.java

public void initComponentsManual() {
    this.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mousePressed(java.awt.event.MouseEvent evt) {
            if (evt.isPopupTrigger()) {
                parent.eventPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
            }/*from   www  . j  a  va 2s  .  c  o  m*/
        }

        public void mouseReleased(java.awt.event.MouseEvent evt) {
            if (evt.isPopupTrigger()) {
                parent.eventPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
            }
        }
    });

    pageSizeField.setDocument(new MirthFieldConstraints(3, false, false, true));
    pageNumberField.setDocument(new MirthFieldConstraints(7, false, false, true));

    LineBorder lineBorder = new LineBorder(new Color(0, 0, 0));
    TitledBorder titledBorder = new TitledBorder("Current Search");
    titledBorder.setBorder(lineBorder);

    lastSearchCriteriaPane.setBorder(titledBorder);
    lastSearchCriteriaPane.setBackground(Color.white);
    lastSearchCriteria.setBackground(Color.white);

    startDatePicker.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent arg0) {
            allDayCheckBox.setEnabled(startDatePicker.getDate() != null || endDatePicker.getDate() != null);
            startTimePicker.setEnabled(startDatePicker.getDate() != null && !allDayCheckBox.isSelected());
        }
    });

    endDatePicker.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent arg0) {
            allDayCheckBox.setEnabled(startDatePicker.getDate() != null || endDatePicker.getDate() != null);
            endTimePicker.setEnabled(endDatePicker.getDate() != null && !allDayCheckBox.isSelected());
        }
    });

    pageNumberField.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent arg0) {
            if (arg0.getKeyCode() == KeyEvent.VK_ENTER && pageGoButton.isEnabled()) {
                jumpToPageNumber();
            }
        }
    });

    updateCachedUserMap();

    advancedSearchPopup = new EventBrowserAdvancedFilter(parent, "Advanced Search Filter", true, userMapById);
    advancedSearchPopup.setVisible(false);

    eventSplitPane.setDividerLocation(0.8);

    this.addAncestorListener(new AncestorListener() {

        @Override
        public void ancestorAdded(AncestorEvent event) {
        }

        @Override
        public void ancestorMoved(AncestorEvent event) {
        }

        @Override
        public void ancestorRemoved(AncestorEvent event) {
            // Stop waiting for event browser requests when the event browser 
            // is no longer being displayed
            parent.mirthClient.getServerConnection().abort(getAbortOperations());
            // Clear the event cache when leaving the event browser.
            parent.eventBrowser.clearCache();
        }

    });
}

From source file:game.Clue.ClueGameUI.java

public void mouseDragged(MouseEvent me) {
    if (player == null) {
        return;//from  w  w w. j av a  2 s. com
    }
    // Scanner scan=new Scanner(System.in);
    int valid = 0;

    player.setLocation(me.getX() + xAdjustment, me.getY() + yAdjustment);

}

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

/**
 * Handle the event//from  w w  w  .j  a v  a2s . c  om
 *
 * @param event the event
 *
 * @return Should we pass on this event
 */
public boolean chartPanelMouseClicked(MouseEvent event) {
    if (SwingUtilities.isRightMouseButton(event) || (event.getClickCount() < 2)) {
        return super.chartPanelMousePressed(event);
    }
    List series = ((MyScatterPlot) plot).getSeries();
    //TODO: Check if click is inside data area
    double minDistance = 100;
    int minIdx = -1;
    double minTime = -1;
    for (int seriesIdx = 0; seriesIdx < series.size(); seriesIdx++) {
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(seriesIdx);
        NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(seriesIdx);
        double[][] data = (double[][]) series.get(seriesIdx);
        for (int i = 0; i < data[0].length; i++) {
            double x = domainAxis.valueToJava2D(data[0][i], getChartPanel().getScreenDataArea(),
                    plot.getDomainAxisEdge());
            double y = rangeAxis.valueToJava2D(data[1][i], getChartPanel().getScreenDataArea(),
                    plot.getRangeAxisEdge());

            double distance = Math
                    .sqrt((x - event.getX()) * (x - event.getX()) + (y - event.getY()) * (y - event.getY()));
            if (distance < minDistance) {
                minDistance = distance;
                minIdx = i;
            }
        }
        if (minIdx >= 0) {
            minTime = timeValues1[minIdx];
        }
    }
    if (minIdx < 0) {
        return EVENT_PASSON;
    }
    firePropertyChange(PROP_SELECTEDTIME, null, new Double(minTime));
    return EVENT_PASSON;
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.PeakListChartPanel.java

public void mouseReleased(MouseEvent e) {
    if (MouseUtils.isPopupTrigger(e)) {
        // clear all
        if (zoom_rectangle != null) {
            Graphics2D g2 = (Graphics2D) getGraphics();
            g2.setXORMode(java.awt.Color.gray);
            g2.draw(zoom_rectangle);//w w  w  . j a  v a  2  s. com
            g2.dispose();
        }
        mouse_start_point = null;
        zoom_rectangle = null;

        // open popup
        current_peak = findPeakAt(e.getPoint());
        enforceSelection(current_peak);
        createPopupMenu(current_peak != null).show(theChartPanel, e.getX(), e.getY());
    } else {
        if (zoom_rectangle != null && mouse_start_point != null) {
            if (Math.abs(e.getX() - mouse_start_point.getX()) > 10) {
                //if( e.getX() < mouse_start_point.getX() ) {
                // unzoom all
                //    onZoomNone();
                //}
                //else {        

                // zoom area           
                double start_x = Math.min(e.getX(), mouse_start_point.getX());
                double end_x = Math.max(e.getX(), mouse_start_point.getX());

                Rectangle2D data_area = theChartPanel.getScreenDataArea((int) start_x,
                        (int) mouse_start_point.getY());
                double new_lower_bound = screenToDataCoordX(start_x);
                double new_upper_bound = screenToDataCoordX(Math.min(end_x, data_area.getMaxX()));
                thePlot.getDomainAxis().setRange(new Range(new_lower_bound, new_upper_bound));
            } else {
                // clear rectangle
                Graphics2D g2 = (Graphics2D) getGraphics();
                g2.setXORMode(java.awt.Color.gray);
                g2.draw(zoom_rectangle);
                g2.dispose();
            }
        }

        // restore zooming
        if (!was_moving && is_moving)
            onActivateZooming();

        zoom_rectangle = null;
        mouse_start_point = null;
    }
}

From source file:game.Clue.ClueGameUI.java

public void mousePressed(MouseEvent e) {
    //player=null;
    Component j = e.getComponent();
    //System.out.println("Click component is : \n"+j.toString()+"\n "+(e.getSource().toString());
    Component c = gameBoard.findComponentAt(e.getX(), e.getY());
    if (c instanceof JPanel) {
        System.out.println("No character chosen");
        return;//from www .ja  v  a 2 s  .  co m
    }

    Point parentLocation = c.getParent().getLocation();
    xAdjustment = parentLocation.x - e.getX();
    yAdjustment = parentLocation.y - e.getY();
    player = (JLabel) c;
    previous_room_x = parentLocation.x + xAdjustment;
    previous_room_y = parentLocation.y + yAdjustment;
    player.setLocation(e.getX() + xAdjustment, e.getY() + yAdjustment);
    player.setSize(player.getWidth(), player.getHeight());
    jLayeredPane5.add(player, JLayeredPane.DRAG_LAYER);

}

From source file:com.xmage.launcher.XMageLauncher.java

private XMageLauncher() {
    locale = Locale.getDefault();
    //locale = new Locale("it", "IT");
    messages = ResourceBundle.getBundle("MessagesBundle", locale);
    localize();/*from   w  w  w  .j  a v a  2s  . c om*/

    serverConsole = new XMageConsole("XMage Server console");
    clientConsole = new XMageConsole("XMage Client console");

    frame = new JFrame(messages.getString("frameTitle") + " " + Config.getVersion());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setPreferredSize(new Dimension(800, 500));
    frame.setResizable(false);

    createToolbar();

    ImageIcon icon = new ImageIcon(XMageLauncher.class.getResource("/icon-mage-flashed.png"));
    frame.setIconImage(icon.getImage());

    Random r = new Random();
    int imageNum = 1 + r.nextInt(17);
    ImageIcon background = new ImageIcon(new ImageIcon(
            XMageLauncher.class.getResource("/backgrounds/" + Integer.toString(imageNum) + ".jpg")).getImage()
                    .getScaledInstance(800, 480, Image.SCALE_SMOOTH));
    mainPanel = new JLabel(background) {
        @Override
        public Dimension getPreferredSize() {
            Dimension size = super.getPreferredSize();
            Dimension lmPrefSize = getLayout().preferredLayoutSize(this);
            size.width = Math.max(size.width, lmPrefSize.width);
            size.height = Math.max(size.height, lmPrefSize.height);
            return size;
        }
    };
    mainPanel.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            grabPoint = e.getPoint();
            mainPanel.getComponentAt(grabPoint);
        }
    });
    mainPanel.addMouseMotionListener(new MouseMotionAdapter() {
        @Override
        public void mouseDragged(MouseEvent e) {

            // get location of Window
            int thisX = frame.getLocation().x;
            int thisY = frame.getLocation().y;

            // Determine how much the mouse moved since the initial click
            int xMoved = (thisX + e.getX()) - (thisX + grabPoint.x);
            int yMoved = (thisY + e.getY()) - (thisY + grabPoint.y);

            // Move window to this position
            int X = thisX + xMoved;
            int Y = thisY + yMoved;
            frame.setLocation(X, Y);
        }
    });
    mainPanel.setLayout(new GridBagLayout());

    GridBagConstraints constraints = new GridBagConstraints();
    constraints.insets = new Insets(10, 10, 10, 10);

    Font font16 = new Font("Arial", Font.BOLD, 16);
    Font font12 = new Font("Arial", Font.PLAIN, 12);
    Font font12b = new Font("Arial", Font.BOLD, 12);

    mainPanel.add(Box.createRigidArea(new Dimension(250, 50)));

    ImageIcon logo = new ImageIcon(new ImageIcon(XMageLauncher.class.getResource("/label-xmage.png")).getImage()
            .getScaledInstance(150, 75, Image.SCALE_SMOOTH));
    xmageLogo = new JLabel(logo);
    constraints.gridx = 3;
    constraints.gridy = 0;
    constraints.gridheight = 1;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    constraints.anchor = GridBagConstraints.EAST;
    mainPanel.add(xmageLogo, constraints);

    textArea = new JTextArea(5, 40);
    textArea.setEditable(false);
    textArea.setForeground(Color.WHITE);
    textArea.setBackground(Color.BLACK);
    DefaultCaret caret = (DefaultCaret) textArea.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    scrollPane = new JScrollPane(textArea);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    constraints.gridx = 2;
    constraints.gridy = 1;
    constraints.weightx = 1.0;
    constraints.weighty = 1.0;
    constraints.fill = GridBagConstraints.BOTH;
    mainPanel.add(scrollPane, constraints);

    labelProgress = new JLabel(messages.getString("progress"));
    labelProgress.setFont(font12);
    labelProgress.setForeground(Color.WHITE);
    constraints.gridy = 2;
    constraints.weightx = 0.0;
    constraints.weighty = 0.0;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.WEST;
    mainPanel.add(labelProgress, constraints);

    progressBar = new JProgressBar(0, 100);
    constraints.gridx = 3;
    constraints.weightx = 1.0;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(progressBar, constraints);

    JPanel pnlButtons = new JPanel();
    pnlButtons.setLayout(new GridBagLayout());
    pnlButtons.setOpaque(false);
    constraints.gridx = 0;
    constraints.gridy = 3;
    constraints.gridheight = GridBagConstraints.REMAINDER;
    constraints.fill = GridBagConstraints.BOTH;
    mainPanel.add(pnlButtons, constraints);

    btnLaunchClient = new JButton(messages.getString("launchClient"));
    btnLaunchClient.setToolTipText(messages.getString("launchClient.tooltip"));
    btnLaunchClient.setFont(font16);
    btnLaunchClient.setForeground(Color.GRAY);
    btnLaunchClient.setEnabled(false);
    btnLaunchClient.setPreferredSize(new Dimension(180, 60));
    btnLaunchClient.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            handleClient();
        }
    });

    constraints.gridx = GridBagConstraints.RELATIVE;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.fill = GridBagConstraints.BOTH;
    pnlButtons.add(btnLaunchClient, constraints);

    btnLaunchClientServer = new JButton(messages.getString("launchClientServer"));
    btnLaunchClientServer.setToolTipText(messages.getString("launchClientServer.tooltip"));
    btnLaunchClientServer.setFont(font12b);
    btnLaunchClientServer.setEnabled(false);
    btnLaunchClientServer.setForeground(Color.GRAY);
    btnLaunchClientServer.setPreferredSize(new Dimension(80, 40));
    btnLaunchClientServer.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            handleServer();
            handleClient();
        }
    });

    constraints.fill = GridBagConstraints.HORIZONTAL;
    pnlButtons.add(btnLaunchClientServer, constraints);

    btnLaunchServer = new JButton(messages.getString("launchServer"));
    btnLaunchServer.setToolTipText(messages.getString("launchServer.tooltip"));
    btnLaunchServer.setFont(font12b);
    btnLaunchServer.setEnabled(false);
    btnLaunchServer.setForeground(Color.GRAY);
    btnLaunchServer.setPreferredSize(new Dimension(80, 40));
    btnLaunchServer.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            handleServer();
        }
    });

    pnlButtons.add(btnLaunchServer, constraints);

    btnUpdate = new JButton(messages.getString("update.xmage"));
    btnUpdate.setToolTipText(messages.getString("update.xmage.tooltip"));
    btnUpdate.setFont(font12b);
    btnUpdate.setForeground(Color.BLACK);
    btnUpdate.setPreferredSize(new Dimension(80, 40));
    btnUpdate.setEnabled(true);

    btnUpdate.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            handleUpdate();
        }
    });

    pnlButtons.add(btnUpdate, constraints);

    btnCheck = new JButton(messages.getString("check.xmage"));
    btnCheck.setToolTipText(messages.getString("check.xmage.tooltip"));
    btnCheck.setFont(font12b);
    btnCheck.setForeground(Color.BLACK);
    btnCheck.setPreferredSize(new Dimension(80, 40));
    btnCheck.setEnabled(true);

    btnCheck.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            handleCheckUpdates();
        }
    });

    pnlButtons.add(btnCheck, constraints);

    frame.add(mainPanel);
    frame.pack();
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation(dim.width / 2 - frame.getSize().width / 2, dim.height / 2 - frame.getSize().height / 2);
}

From source file:org.jax.maanova.madata.gui.ArrayScatterPlotPanel.java

private void mouseMoved(MouseEvent e) {
    if (this.showTooltip) {
        Point2D chartPoint = this.chartPanel.toChartPoint(e.getPoint());

        // find the nearest probe
        XYProbeData xyProbeData = this.getXYData();
        double nearestDistance = Double.POSITIVE_INFINITY;
        int nearestDotIndex = -1;
        double[] xData = xyProbeData.getXData();
        double[] yData = xyProbeData.getYData();
        for (int dotIndex = 0; dotIndex < xData.length; dotIndex++) {
            double currDist = chartPoint.distanceSq(xData[dotIndex], yData[dotIndex]);
            if (currDist < nearestDistance) {
                nearestDistance = currDist;
                nearestDotIndex = dotIndex;
            }/* w  ww . ja v a  2s  .co  m*/
        }

        if (nearestDotIndex == -1) {
            this.clearProbePopup();
        } else {
            Point2D probeJava2DCoord = this.getJava2DCoordinates(xData[nearestDotIndex],
                    yData[nearestDotIndex]);
            double java2DDist = probeJava2DCoord.distance(e.getX(), e.getY());

            // is the probe close enough to be worth showing (in pixel distance)
            if (java2DDist <= PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS * 2) {
                this.showProbePopup(xyProbeData.getProbeIndices()[nearestDotIndex], xData[nearestDotIndex],
                        yData[nearestDotIndex], e.getX(), e.getY());
            } else {
                this.clearProbePopup();
            }
        }
    }
}

From source file:com.intuit.tank.proxy.ProxyApp.java

private JPanel getTransactionTable() {
    JPanel frame = new JPanel(new BorderLayout());
    model = new TransactionTableModel();
    final JTable table = new TransactionTable(model);
    final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model);
    table.setRowSorter(sorter);/*w w  w .j av  a2 s. c  o m*/
    final JPopupMenu pm = new JPopupMenu();
    JMenuItem item = new JMenuItem("Delete Selected");
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            int[] selectedRows = table.getSelectedRows();
            if (selectedRows.length != 0) {
                int response = JOptionPane.showConfirmDialog(ProxyApp.this,
                        "Are you sure you want to delete " + selectedRows.length + " Transactions?",
                        "Confirm Delete", JOptionPane.YES_NO_OPTION);
                if (response == JOptionPane.YES_OPTION) {
                    int[] correctedRows = new int[selectedRows.length];
                    for (int i = selectedRows.length; --i >= 0;) {
                        int row = selectedRows[i];
                        int index = (Integer) table.getValueAt(row, 0) - 1;
                        correctedRows[i] = index;
                    }
                    Arrays.sort(correctedRows);
                    for (int i = correctedRows.length; --i >= 0;) {
                        int row = correctedRows[i];
                        Transaction transaction = model.getTransactionForIndex(row);
                        if (transaction != null) {
                            model.removeTransaction(transaction, row);
                            isDirty = true;
                            saveAction.setEnabled(isDirty && !stopAction.isEnabled());
                        }
                    }
                }
            }
        }
    });
    pm.add(item);
    table.add(pm);

    table.addMouseListener(new MouseAdapter() {
        boolean pressed = false;

        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                Point p = e.getPoint();
                int row = table.rowAtPoint(p);
                int index = (Integer) table.getValueAt(row, 0) - 1;
                Transaction transaction = model.getTransactionForIndex(index);
                if (transaction != null) {
                    detailsTF.setText(transaction.toString());
                    detailsTF.setCaretPosition(0);
                    detailsDialog.setVisible(true);
                }
            }
        }

        /**
         * @{inheritDoc
         */
        @Override
        public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) {
                pressed = true;
                int[] selectedRows = table.getSelectedRows();
                if (selectedRows.length != 0) {
                    pm.show(e.getComponent(), e.getX(), e.getY());
                }
            }
        }

        /**
         * @{inheritDoc
         */
        @Override
        public void mouseReleased(MouseEvent e) {
            if (!pressed && e.isPopupTrigger()) {
                int[] selectedRows = table.getSelectedRows();
                if (selectedRows.length != 0) {
                    pm.show(e.getComponent(), e.getX(), e.getY());
                }
            }
        }

    });

    JScrollPane pane = new JScrollPane(table);
    frame.add(pane, BorderLayout.CENTER);
    JPanel panel = new JPanel(new BorderLayout());
    JLabel label = new JLabel("Filter: ");
    panel.add(label, BorderLayout.WEST);
    final JLabel countLabel = new JLabel(" Count: 0 ");
    panel.add(countLabel, BorderLayout.EAST);
    final JTextField filterText = new JTextField("");
    filterText.addKeyListener(new KeyAdapter() {
        public void keyTyped(KeyEvent e) {
            String text = filterText.getText();
            if (text.length() == 0) {
                sorter.setRowFilter(null);
            } else {
                try {
                    sorter.setRowFilter(RowFilter.regexFilter(text));
                    countLabel.setText(" Count: " + sorter.getViewRowCount() + " ");
                } catch (PatternSyntaxException pse) {
                    System.err.println("Bad regex pattern");
                }
            }
        }
    });
    panel.add(filterText, BorderLayout.CENTER);

    frame.add(panel, BorderLayout.NORTH);
    return frame;
}