Example usage for java.awt.event MouseEvent getSource

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

Introduction

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

Prototype

public Object getSource() 

Source Link

Document

The object on which the Event initially occurred.

Usage

From source file:graph.eventhandlers.MyEditingGraphMousePlugin.java

/**
 * If startVertex is non-null, stretch an edge shape between startVertex and
 * the mouse pointer to simulate edge creation
 */// w  w  w. j av a  2 s  .  c  om
public void mouseDragged(MouseEvent e) {
    if (checkModifiers(e)) {
        if (startVertex != null) {
            transformEdgeShape(down, e.getPoint());
            if (edgeIsDirected) {
                transformArrowShape(down, e.getPoint());
            }
        }
        VisualizationViewer<BiologicalNodeAbstract, BiologicalEdgeAbstract> vv = (VisualizationViewer<BiologicalNodeAbstract, BiologicalEdgeAbstract>) e
                .getSource();
        vv.repaint();
    }
}

From source file:canreg.client.gui.analysis.FrequenciesByYearInternalFrame.java

/**
 *
 * @param offset//from  w  w w .jav a 2 s.c  om
 * @param evt
 */
public void showPopUpMenu(int offset, java.awt.event.MouseEvent evt) {
    JTable target = (JTable) evt.getSource();
    int rowNumber = target.rowAtPoint(new Point(evt.getX(), evt.getY()));
    rowNumber = target.convertRowIndexToModel(rowNumber);

    JPopupMenu jpm = new JPopupMenu();
    jpm.add(java.util.ResourceBundle
            .getBundle("canreg/client/gui/analysis/resources/FrequenciesByYearInternalFrame")
            .getString("SHOW_IN_BROWSER"));
    TableModel tableModel = target.getModel();
    // resultTable.get
    // jpm.add("Column " + rowNumber +" " + tableColumnModel.getColumn(tableColumnModel.getColumnIndexAtX(evt.getX())).getHeaderValue());
    int year = Integer.parseInt((String) tableModel.getValueAt(rowNumber, 0));

    String filterString = "INCID >= '" + year * 10000 + "' AND INCID <'" + (year + 1) * 10000 + "'";

    for (DatabaseVariablesListElement dvle : chosenVariables) {
        int columnNumber = tableColumnModel
                .getColumnIndex(canreg.common.Tools.toUpperCaseStandardized(dvle.getDatabaseVariableName()));
        String value = tableModel.getValueAt(rowNumber, columnNumber).toString();
        filterString += " AND " + canreg.common.Tools.toUpperCaseStandardized(dvle.getDatabaseVariableName())
                + " = " + dvle.getSQLqueryFormat(value);
    }
    DatabaseFilter filter = new DatabaseFilter();
    filter.setFilterString(filterString);
    Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.INFO, "FilterString: {0}",
            filterString);
    try {
        tableDatadescriptionPopUp = canreg.client.CanRegClientApp.getApplication()
                .getDistributedTableDescription(filter, rangeFilterPanel.getSelectedTable());
        Object[][] rows = canreg.client.CanRegClientApp.getApplication().retrieveRows(
                tableDatadescriptionPopUp.getResultSetID(), 0, MAX_ENTRIES_DISPLAYED_ON_RIGHT_CLICK);
        String[] variableNames = tableDatadescriptionPopUp.getColumnNames();
        for (Object[] row : rows) {
            String line = "";
            int i = 0;
            for (Object obj : row) {
                if (obj != null) {
                    line += variableNames[i] + ": " + obj.toString() + ", ";
                }
                i++;
            }
            jpm.add(line);
        }
    } catch (SQLException ex) {
        Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
    } catch (RemoteException ex) {
        Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SecurityException ex) {
        Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DistributedTableDescriptionException ex) {
        Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
    } catch (UnknownTableException ex) {
        Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
    }

    int cases = (Integer) tableModel.getValueAt(rowNumber, tableColumnModel.getColumnIndex("CASES"));
    if (MAX_ENTRIES_DISPLAYED_ON_RIGHT_CLICK < cases) {
        jpm.add("...");
    }
    MenuItem menuItem = new MenuItem();

    jpm.show(target, evt.getX(), evt.getY());
}

From source file:canreg.client.gui.analysis.FrequenciesByYearInternalFrame.java

private void columnTableMousePressed(java.awt.event.MouseEvent evt) {
    if (evt.getButton() == java.awt.event.MouseEvent.BUTTON3) {
        JTable target = (JTable) evt.getSource();
        int columnNumber = target.getSelectedColumn();

        JPopupMenu jpm = new JPopupMenu("" + columnNumber);
        jpm.add(java.util.ResourceBundle
                .getBundle("canreg/client/gui/analysis/resources/FrequenciesByYearInternalFrame")
                .getString("COLUMN ")
                + tableColumnModel.getColumn(tableColumnModel.getColumnIndexAtX(evt.getX())).getHeaderValue());
        jpm.show(target, evt.getX(), evt.getY());
    }/*from   w w  w  .  j a  v  a 2s.  co  m*/
}

From source file:fll.subjective.SubjectiveFrame.java

/**
 * Show differences./*w  w  w. j a  v  a  2s .co  m*/
 */
private void showDifferencesDialog(final Collection<SubjectiveScoreDifference> diffs) {
    final SubjectiveDiffTableModel model = new SubjectiveDiffTableModel(diffs);
    final JTable table = new JTable(model);
    table.setGridColor(Color.BLACK);

    table.addMouseListener(new MouseAdapter() {
        public void mouseClicked(final MouseEvent e) {
            if (e.getClickCount() == 2) {
                final JTable target = (JTable) e.getSource();
                final int row = target.getSelectedRow();

                final SubjectiveScoreDifference diff = model.getDiffForRow(row);

                // find correct table
                final String category = diff.getCategory();
                final JTable scoreTable = getTableForTitle(category);
                final int tabIndex = getTabIndexForCategory(category);
                getTabbedPane().setSelectedIndex(tabIndex);

                // get correct row and column
                final SubjectiveTableModel model = (SubjectiveTableModel) scoreTable.getModel();
                final int scoreRow = model.getRowForTeamAndJudge(diff.getTeamNumber(), diff.getJudge());
                final int scoreCol = model.getColForSubcategory(diff.getSubcategory());
                if (scoreRow == -1 || scoreCol == -1) {
                    throw new FLLRuntimeException(
                            "Internal error: Cannot find correct row and column for score difference: " + diff);
                }

                scoreTable.changeSelection(scoreRow, scoreCol, false, false);
            }
        }
    });

    final JDialog dialog = new JDialog(this, false);
    final Container cpane = dialog.getContentPane();
    cpane.setLayout(new BorderLayout());
    final JScrollPane tableScroller = new JScrollPane(table);
    cpane.add(tableScroller, BorderLayout.CENTER);

    dialog.pack();
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setVisible(true);
}

From source file:HelloUniverse.java

public void mousePressed(MouseEvent e) {
    if (e.getSource() == leftB && mode != MOVING_LEFT) {
        time_last_state_change = System.currentTimeMillis();
        mode = MOVING_LEFT;//from  w w  w .ja v a 2 s.c  om
        orig_position.set(position);
    } else if (e.getSource() == rightB && mode != MOVING_RIGHT) {
        time_last_state_change = System.currentTimeMillis();
        mode = MOVING_RIGHT;
        orig_position.set(position);
    } else if (e.getSource() == upB && mode != MOVING_UP) {
        time_last_state_change = System.currentTimeMillis();
        mode = MOVING_UP;
        orig_position.set(position);
    } else if (e.getSource() == downB && mode != MOVING_DOWN) {
        time_last_state_change = System.currentTimeMillis();
        mode = MOVING_DOWN;
        orig_position.set(position);
    } else if (e.getSource() == forwardB && mode != MOVING_FORWARD) {
        time_last_state_change = System.currentTimeMillis();
        mode = MOVING_FORWARD;
        orig_position.set(position);
    } else if (e.getSource() == backwardB && mode != MOVING_BACK) {
        time_last_state_change = System.currentTimeMillis();
        mode = MOVING_BACK;
        orig_position.set(position);
    } else if (e.getSource() == reset) {
        device.setNominalPositionAndOrientation();
    }
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.ToolBar.java

/** Initializes the components. */
private void initComponents() {
    setBackground(UIUtilities.BACKGROUND_COLOR);
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    IconManager icons = IconManager.getInstance();
    saveButton = new JButton(icons.getIcon(IconManager.SAVE));
    saveButton.setToolTipText("Save changes back to the server.");
    saveButton.addActionListener(controller);
    saveButton.setActionCommand("" + EditorControl.SAVE);
    saveButton.setEnabled(false);/*ww w  . j  a v a 2s.  com*/
    saveButton.setBackground(UIUtilities.BACKGROUND_COLOR);

    downloadButton = new JButton(icons.getIcon(IconManager.DOWNLOAD));
    downloadButton.setToolTipText("Download the Archived File(s).");
    downloadButton.addActionListener(controller);
    downloadButton.setActionCommand("" + EditorControl.DOWNLOAD);
    //downloadButton.setEnabled(false);
    downloadButton.setBackground(UIUtilities.BACKGROUND_COLOR);

    rndButton = new JButton(icons.getIcon(IconManager.RENDERER));
    rndButton.setToolTipText("Rendering control for the first selected " + "image.");
    rndButton.addActionListener(controller);
    rndButton.setActionCommand("" + EditorControl.RENDERER);
    rndButton.setEnabled(false);
    rndButton.setBackground(UIUtilities.BACKGROUND_COLOR);

    refreshButton = new JButton(icons.getIcon(IconManager.REFRESH));
    refreshButton.setToolTipText("Refresh.");
    refreshButton.addActionListener(controller);
    refreshButton.setActionCommand("" + EditorControl.REFRESH);
    refreshButton.setBackground(UIUtilities.BACKGROUND_COLOR);

    publishingButton = new JButton(icons.getIcon(IconManager.PUBLISHING));
    publishingButton.setToolTipText("Display the publishing options.");
    publishingButton.setEnabled(false);
    publishingButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    publishingButton.addMouseListener(new MouseAdapter() {

        /**
         * Launches the dialog when the user releases the mouse.
         * MouseAdapter#mouseReleased(MouseEvent)
         */
        public void mouseReleased(MouseEvent e) {
            launchOptions((Component) e.getSource(), e.getPoint(), MetadataViewer.PUBLISHING_OPTION);
        }
    });
    analysisButton = new JButton(icons.getIcon(IconManager.ANALYSIS));
    analysisButton.setToolTipText("Display the analysis options.");
    analysisButton.setEnabled(false);
    analysisButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    analysisButton.addMouseListener(new MouseAdapter() {

        /**
         * Launches the dialog when the user releases the mouse.
         * MouseAdapter#mouseReleased(MouseEvent)
         */
        public void mouseReleased(MouseEvent e) {
            launchOptions((Component) e.getSource(), e.getPoint(), MetadataViewer.ANALYSIS_OPTION);
        }
    });
    scriptsButton = new JButton(icons.getIcon(IconManager.ANALYSIS_RUN));
    scriptsButton.setToolTipText("Display the available scripts.");
    scriptsButton.setEnabled(false);
    scriptsButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    scriptsButton.addMouseListener(new MouseAdapter() {

        /**
         * Loads the scripts of displays them if already loaded.
         * MouseAdapter#mousePressed(MouseEvent)
         */
        public void mouseReleased(MouseEvent e) {
            if (model.getScripts() == null) {
                location = e.getPoint();
                scriptsButton.setEnabled(false);
                model.loadScripts();
                setStatus(true);
            } else {
                launchOptions((Component) e.getSource(), e.getPoint(), MetadataViewer.SCRIPTS_OPTION);
            }
        }
    });
    exportAsOmeTiffButton = new JButton(icons.getIcon(IconManager.EXPORT_AS_OMETIFF));
    exportAsOmeTiffButton.setEnabled(false);
    exportAsOmeTiffButton.setToolTipText(EXPORT_AS_OME_TIFF_TOOLTIP);
    exportAsOmeTiffButton.addActionListener(controller);
    exportAsOmeTiffButton.setActionCommand("" + EditorControl.EXPORT_AS_OMETIFF);
    exportAsOmeTiffButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    uploadScriptButton = new JButton(icons.getIcon(IconManager.UPLOAD_SCRIPT));
    uploadScriptButton.setToolTipText("Upload a script to the server.");
    uploadScriptButton.addActionListener(controller);
    uploadScriptButton.setActionCommand("" + EditorControl.UPLOAD_SCRIPT);
    uploadScriptButton.setBackground(UIUtilities.BACKGROUND_COLOR);

    saveAsButton = new JButton(icons.getIcon(IconManager.EXPORT_AS_OMETIFF));
    saveAsButton.setToolTipText("Display the saving options.");
    saveAsButton.addMouseListener(new MouseAdapter() {

        /**
         * Displays the saving options.
         * MouseAdapter#mousePressed(MouseEvent)
         */
        public void mouseReleased(MouseEvent e) {
            launchOptions((Component) e.getSource(), e.getPoint(), MetadataViewer.SAVE_OPTION);
        }
    });
    saveAsButton.setBackground(UIUtilities.BACKGROUND_COLOR);

    viewButton = new JButton(icons.getIcon(IconManager.VIEW));
    viewButton.setToolTipText("Open the Image Viewer");
    if (MetadataViewerAgent.runAsPlugin() == MetadataViewer.IMAGE_J) {
        viewButton.addMouseListener(new MouseAdapter() {

            /**
             * Displays the <code>view</code> menu.
             * @see MouseListener#mouseReleased(MouseEvent)
             */
            public void mouseReleased(MouseEvent e) {
                showViewMenu((Component) e.getSource(), e.getPoint());
            }
        });
    } else {
        viewButton.setActionCommand("" + EditorControl.VIEW_IMAGE);
        viewButton.addActionListener(controller);
    }
    linkButton = new JButton(icons.getIcon(IconManager.LINK));
    linkButton.addMouseListener(new MouseAdapter() {

        /**
         * Launches the dialog when the user releases the mouse.
         * MouseAdapter#mouseReleased(MouseEvent)
         */
        public void mouseReleased(MouseEvent e) {
            location = e.getPoint();
            component = (Component) e.getSource();
            createLinkMenu().show(component, location.x, location.y);
        }
    });

    UIUtilities.unifiedButtonLookAndFeel(linkButton);
    UIUtilities.unifiedButtonLookAndFeel(viewButton);
    UIUtilities.unifiedButtonLookAndFeel(saveAsButton);
    UIUtilities.unifiedButtonLookAndFeel(saveButton);
    UIUtilities.unifiedButtonLookAndFeel(downloadButton);
    UIUtilities.unifiedButtonLookAndFeel(rndButton);
    UIUtilities.unifiedButtonLookAndFeel(refreshButton);
    UIUtilities.unifiedButtonLookAndFeel(exportAsOmeTiffButton);
    UIUtilities.unifiedButtonLookAndFeel(publishingButton);
    UIUtilities.unifiedButtonLookAndFeel(uploadScriptButton);
    UIUtilities.unifiedButtonLookAndFeel(analysisButton);
    UIUtilities.unifiedButtonLookAndFeel(scriptsButton);

    Dimension d = new Dimension(UIUtilities.DEFAULT_ICON_WIDTH, UIUtilities.DEFAULT_ICON_HEIGHT);
    busyLabel = new JXBusyLabel(d);
    busyLabel.setEnabled(true);
    busyLabel.setVisible(false);
}

From source file:ro.nextreports.designer.querybuilder.SelectionColumnPanel.java

private void buildUI() {

    setLayout(new GridBagLayout());

    final DBViewer viewer = Globals.getDBViewer();

    schemaCombo = new JComboBox();
    schemaCombo.setPreferredSize(comboDim);

    schemaCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            String schema = (String) e.getItem();
            shownColumnModel.clear();//from   ww  w .jav a  2  s  .  c  om
            columnModel.clear();
            tableModel.clear();
            try {
                DBInfo dbInfo = viewer.getDBInfo(schema, DBInfo.TABLES | DBInfo.VIEWS);
                List<DBTable> tables = dbInfo.getTables();
                Collections.sort(tables);
                for (DBTable table : tables) {
                    tableModel.addElement(table);
                }
            } catch (NextSqlException ex) {
                LOG.error(ex.getMessage(), ex);
                ex.printStackTrace();
            }
        }
    });

    try {
        List<String> schemas = viewer.getSchemas();
        String schemaName = viewer.getUserSchema();
        Collections.sort(schemas);
        boolean added = false;
        for (String schema : schemas) {
            if (DefaultSchemaManager.getInstance().isVisible(
                    DefaultDataSourceManager.getInstance().getConnectedDataSource().getName(), schema)) {
                added = true;
                schemaCombo.addItem(schema);
            }
        }

        if ((schema == null) || schema.equals(DefaultDBViewer.NO_SCHEMA_NAME)) {
            schema = DefaultDBViewer.NO_SCHEMA_NAME;//viewer.getUserSchema();
        }
        if (!added) {
            schemaCombo.addItem(schema);
        }
        schemaCombo.setSelectedItem(schema);
    } catch (NextSqlException e) {
        LOG.error(e.getMessage(), e);
        e.printStackTrace();
    }

    // create table list
    tableList = new JXList(tableModel);
    tableList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tableList.setCellRenderer(new DBTableCellRenderer());

    // create column list
    columnList = new JXList(columnModel);
    if (singleSelection) {
        columnList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    } else {
        columnList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    }
    columnList.setCellRenderer(new DBColumnCellRenderer());

    shownColumnList = new JXList(shownColumnModel);
    if (singleSelection) {
        shownColumnList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    } else {
        columnList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    }
    addDoubleClick();

    shownColumnList.setCellRenderer(new DBColumnCellRenderer());
    shownColumnList.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent mouseEvent) {
            if ((mouseEvent.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) {
                JPopupMenu popupMenu = new JPopupMenu();
                JMenuItem menuItem = new JMenuItem(new DeselectListAction(shownColumnList));
                popupMenu.add(menuItem);
                popupMenu.show((Component) mouseEvent.getSource(), mouseEvent.getX(), mouseEvent.getY());
            }
        }
    });

    tableList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting() == false) {
                int index = tableList.getSelectedIndex();
                if (index == -1) {
                    return;
                }
                DBTable table = (DBTable) tableModel.getElementAt(index);
                try {
                    List<DBColumn> columns = null;
                    try {
                        columns = viewer.getColumns(table.getSchema(), table.getName());
                    } catch (MalformedTableNameException e1) {
                        Show.error("Malformed table name : " + table.getName());
                        return;
                    }
                    Collections.sort(columns);
                    columnModel.clear();
                    shownColumnModel.clear();
                    for (DBColumn column : columns) {
                        columnModel.addElement(column);
                        shownColumnModel.addElement(column);
                    }
                } catch (NextSqlException e1) {
                    LOG.error(e1.getMessage(), e1);
                    e1.printStackTrace();
                    Show.error(e1);
                }
            }
        }
    });

    columnList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            shownColumnList.clearSelection();
        }
    });

    scrTable = new JScrollPane(tableList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrTable.setPreferredSize(scrDim);
    scrTable.setMinimumSize(scrDim);
    scrTable.setBorder(new TitledBorder(I18NSupport.getString("parameter.source.tables")));
    scrColumn = new JScrollPane(columnList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrColumn.setPreferredSize(scrDim);
    scrColumn.setMinimumSize(scrDim);
    scrColumn.setBorder(new TitledBorder(I18NSupport.getString("parameter.source.columns")));
    scrShownColumn = new JScrollPane(shownColumnList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrShownColumn.setPreferredSize(scrDim);
    scrShownColumn.setMinimumSize(scrDim);
    scrShownColumn.setBorder(new TitledBorder(I18NSupport.getString("parameter.source.shown.columns")));

    JPanel schemaPanel = new JPanel();
    schemaPanel.setLayout(new BoxLayout(schemaPanel, BoxLayout.X_AXIS));
    schemaPanel.add(new JLabel("Schema"));
    schemaPanel.add(Box.createHorizontalStrut(5));
    schemaPanel.add(schemaCombo);

    add(schemaPanel, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    add(scrTable, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 5), 0, 0));
    add(scrColumn, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));
    if (show) {
        add(scrShownColumn, new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
                GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    }
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.EditorControl.java

/**
 * Removes the tags or files.//from  w  w  w  . ja  va2s  .c  o  m
 * @see MouseListener#mouseReleased(MouseEvent)
 */
public void mouseReleased(MouseEvent e) {
    JButton src = (JButton) e.getSource();
    if (!src.isEnabled())
        return;
    int index = Integer.parseInt(src.getActionCommand());
    Point p = e.getPoint();
    switch (index) {
    case REMOVE_TAGS:
        view.removeTags(src, p);
        break;
    case REMOVE_DOCS:
        view.removeAttachedFiles(src, p);
        break;
    case REMOVE_OTHER_ANNOTATIONS:
        view.removeOtherAnnotations(src, p);
    }
}

From source file:org.zaproxy.zap.extension.multiFuzz.impl.http.HttpFuzzResultDialog.java

@Override
public JXTreeTable getTable() {
    if (table == null) {
        if (model == null) {
            model = new HttpFuzzTableModel();
        }//  ww w. j a va  2 s . co m
        table = new JXTreeTable(model);
        table.setDoubleBuffered(true);
        table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        table.setName("HttpFuzzResultTable");
        table.setFont(new java.awt.Font("Default", java.awt.Font.PLAIN, 12));
        table.setDefaultRenderer(Pair.class, new IconTableCellRenderer());

        int[] widths = { 10, 25, 550, 30, 85, 55, 40, 70 };
        for (int i = 0, count = widths.length; i < count; i++) {
            TableColumn column = table.getColumnModel().getColumn(i);
            column.setPreferredWidth(widths[i]);
        }
        table.addMouseListener(new java.awt.event.MouseAdapter() {
            @Override
            public void mousePressed(java.awt.event.MouseEvent e) {
                showPopupMenuIfTriggered(e);
            }

            @Override
            public void mouseReleased(java.awt.event.MouseEvent e) {
                showPopupMenuIfTriggered(e);
            }

            private void showPopupMenuIfTriggered(java.awt.event.MouseEvent e) {
                if (e.isPopupTrigger()) {
                    if (e.isPopupTrigger()) {
                        // Select list item on right click
                        JTable table = (JTable) e.getSource();
                        int row = table.rowAtPoint(e.getPoint());

                        if (!table.isRowSelected(row)) {
                            table.changeSelection(row, 0, false, false);
                        }
                        View.getSingleton().getPopupMenu().show(e.getComponent(), e.getX(), e.getY());
                    }
                }
            }

        });
        table.getSelectionModel().addListSelectionListener(new javax.swing.event.ListSelectionListener() {

            @Override
            public void valueChanged(javax.swing.event.ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                    if (table.getSelectedRowCount() == 0) {
                        return;
                    }
                    final int row = table.getSelectedRow();
                    if (getEntry(row) instanceof HttpFuzzRequestRecord) {
                        final HistoryReference historyReference = ((HttpFuzzRequestRecord) getEntry(row))
                                .getHistory();
                        try {
                            getMessageInspection().setMessage(historyReference.getHttpMessage());
                        } catch (HttpMalformedHeaderException | SQLException ex) {
                            logger.error(ex.getMessage(), ex);
                        }
                    }
                    updateValues();
                    redrawDiagrams();
                }
            }
        });
    }
    table.getTableHeader().addMouseListener(new MouseListener() {
        int sortedOn = -1;

        @Override
        public void mouseReleased(MouseEvent arg0) {
        }

        @Override
        public void mousePressed(MouseEvent arg0) {
        }

        @Override
        public void mouseExited(MouseEvent arg0) {
        }

        @Override
        public void mouseEntered(MouseEvent arg0) {
        }

        @Override
        public void mouseClicked(MouseEvent e) {
            int index = table.columnAtPoint(e.getPoint());
            List<HttpFuzzRecord> list = model.getEntries();
            if (list.size() == 0) {
                return;
            }
            HttpFuzzRecordComparator comp = new HttpFuzzRecordComparator();
            comp.setFeature(index);
            if (index == sortedOn) {
                Collections.sort(list, comp);
                Collections.reverse(list);
                sortedOn = -1;
            } else {
                Collections.sort(list, comp);
                sortedOn = index;
            }
            table.updateUI();
        }
    });
    table.setRootVisible(false);
    table.setVisible(true);
    return table;
}

From source file:com.floreantpos.jasperreport.swing.JRViewerPanel.java

void hyperlinkClicked(MouseEvent evt) {
    JPanel link = (JPanel) evt.getSource();
    JRPrintHyperlink element = (JRPrintHyperlink) linksMap.get(link);
    hyperlinkClicked(element);/*from  w w  w.j a  va  2  s  . c  o  m*/
}