List of usage examples for java.awt.event MouseEvent getPoint
public Point getPoint()
From source file:org.tellervo.desktop.tridasv2.ui.ComponentViewer.java
private void setupTable() { tableModel = new ElementListTableModel(); table = new JXTable(tableModel); tableSorter = new ElementListTableSorter(tableModel, table); table.getTableHeader().addMouseListener(tableSorter); // add sorter & header renderer table.setColumnSelectionAllowed(false); table.setRowSelectionAllowed(true);//from w w w. j a v a 2s .co m // set our column widths ElementListTableModel.setupColumnWidths(table); table.setDefaultRenderer(Object.class, new ElementListCellRenderer(this, false)); table.setDefaultRenderer(Boolean.class, new BooleanCellRenderer(this, false)); // hide irrelevent columns TableColumnModelExt colmodel = (TableColumnModelExt) table.getColumnModel(); table.setColumnControlVisible(true); colmodel.getColumnExt(I18n.getText("hidden.MostRecentVersion")).setVisible(false); colmodel.getColumnExt(I18n.getText("dbbrowser.n")).setVisible(false); colmodel.getColumnExt(I18n.getText("dbbrowser.rec")).setVisible(false); colmodel.getColumnExt(I18n.getText("dbbrowser.hash")).setVisible(false); // popup menu table.addMouseListener(new PopupListener() { @Override public void showPopup(MouseEvent e) { // only clicks on tables if (!(e.getSource() instanceof JTable)) return; JTable table = (JTable) e.getSource(); ElementListTableModel model = (ElementListTableModel) table.getModel(); // get the row and sanity check int row = table.rowAtPoint(e.getPoint()); if (row < 0 || row >= model.getRowCount()) return; // select it? table.setRowSelectionInterval(row, row); // get the element Element element = model.getElementAt(row); // create and show the menu JPopupMenu popup = new ElementListPopupMenu(element, ComponentViewer.this); popup.show(table, e.getX(), e.getY()); } }); }
From source file:it.iit.genomics.cru.igb.bundles.mi.view.MITable.java
@Override public String getToolTipText(MouseEvent e) { String tip = null;/*from w ww.jav a 2s . co m*/ java.awt.Point p = e.getPoint(); int rowIndex = rowAtPoint(p); int colIndex = columnAtPoint(p); try { ToolTipManager.sharedInstance().setInitialDelay(500); if (colIndex == MITableModel.STRUCTURES_COLUMN) { return ""; } // comment row, exclude heading if (rowIndex >= 0) { int modelRow = rowAtPoint(e.getPoint()); // getSelectedRow(); //convertRowIndexToModel(getSelectedRow()); Object value = getValueAt(modelRow, colIndex); if (colIndex == MITableModel.SYMS1_COLUMN || colIndex == MITableModel.SYMS2_COLUMN || colIndex == MITableModel.INTERACTOR1_COLUMN || colIndex == MITableModel.INTERACTOR2_COLUMN) { MoleculeEntry entry = (MoleculeEntry) value; tip = entry.getGeneName() + " (" + entry.getUniprotAc() + ", " + entry.getOrganism() + ")"; } else if (colIndex == MITableModel.TRACK_COLUMN) { if (JButton.class.isInstance(value)) { tip = "Press this button to create a new track for this interaction"; } else { tip = ((JLabel) value).getText(); } } else if (colIndex == MITableModel.INTERACTION_TYPE_COLUMN) { Interaction interaction = (Interaction) value; tip = "<html>Type: " + StringUtils.join(interaction.getInteractionTypes(), ", ") + "<br/>Method: " + StringUtils.join(interaction.getMethods(), ", ") + "<br/>Bibliographic references: " + StringUtils.join(interaction.getBibRefs(), ", ") + "</html>"; } else { tip = value.toString(); } } } catch (RuntimeException e1) { igbLogger.getLogger().error("exception, row " + rowIndex, e1); // catch null pointer exception if mouse is over an empty line } return tip; }
From source file:me.mayo.telnetkek.MainPanel.java
public final void setupTablePopup() { this.tblPlayers.addMouseListener(new MouseAdapter() { @Override//from www. jav a2 s.c om public void mouseReleased(final MouseEvent mouseEvent) { final JTable table = MainPanel.this.tblPlayers; final int r = table.rowAtPoint(mouseEvent.getPoint()); if (r >= 0 && r < table.getRowCount()) { table.setRowSelectionInterval(r, r); } else { table.clearSelection(); } final int rowindex = table.getSelectedRow(); if (rowindex < 0) { return; } if ((SwingUtilities.isRightMouseButton(mouseEvent) || mouseEvent.isControlDown()) && mouseEvent.getComponent() instanceof JTable) { final PlayerInfo player = getSelectedPlayer(); if (player != null) { final JPopupMenu popup = new JPopupMenu(player.getName()); final JMenuItem header = new JMenuItem("Apply action to " + player.getName() + ":"); header.setEnabled(false); popup.add(header); popup.addSeparator(); final ActionListener popupAction = (ActionEvent actionEvent) -> { Object _source = actionEvent.getSource(); if (_source instanceof PlayerListPopupItem_Command) { final PlayerListPopupItem_Command source = (PlayerListPopupItem_Command) _source; final String output = source.getCommand().buildOutput(source.getPlayer(), true); MainPanel.this.getConnectionManager().sendDelayedCommand(output, true, 100); } else if (_source instanceof PlayerListPopupItem) { final PlayerListPopupItem source = (PlayerListPopupItem) _source; final PlayerInfo _player = source.getPlayer(); switch (actionEvent.getActionCommand()) { case "Copy IP": { copyToClipboard(_player.getIp()); MainPanel.this.writeToConsole( new ConsoleMessage("Copied IP to clipboard: " + _player.getIp())); break; } case "Copy Name": { copyToClipboard(_player.getName()); MainPanel.this.writeToConsole( new ConsoleMessage("Copied name to clipboard: " + _player.getName())); break; } case "Copy UUID": { copyToClipboard(_player.getUuid()); MainPanel.this.writeToConsole( new ConsoleMessage("Copied UUID to clipboard: " + _player.getUuid())); break; } } } }; TelnetKek.config.getCommands().stream().map( (command) -> new PlayerListPopupItem_Command(command.getName(), player, command)) .map((item) -> { item.addActionListener(popupAction); return item; }).forEach((item) -> { popup.add(item); }); popup.addSeparator(); JMenuItem item; item = new PlayerListPopupItem("Copy Name", player); item.addActionListener(popupAction); popup.add(item); item = new PlayerListPopupItem("Copy IP", player); item.addActionListener(popupAction); popup.add(item); item = new PlayerListPopupItem("Copy UUID", player); item.addActionListener(popupAction); popup.add(item); popup.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY()); } } } }); }
From source file:com.qspin.qtaste.ui.reporter.TestCaseReportTable.java
private void init() { final String tableLayoutProperty = interactive ? INTERACTIVE_TABLE_LAYOUT_PROPERTY : EXECUTION_TABLE_LAYOUT_PROPERTY; final String statusColumnProperty = tableLayoutProperty + ".status"; final String testCaseColumnProperty = tableLayoutProperty + ".test_case"; final String detailsColumnProperty = tableLayoutProperty + ".details"; final String testbedColumnProperty = tableLayoutProperty + ".testbed"; final String resultColumnProperty = tableLayoutProperty + ".result"; tcModel = new DefaultTableModel( new Object[] { "Status", "Test Case", "Details", "Result", "Testbed", "Time", "." }, 0) { @Override//from ww w . j a v a 2 s. c o m public Class<?> getColumnClass(int columnIndex) { Class<?> dataType = super.getColumnClass(columnIndex); if (columnIndex == STATUS) { dataType = Icon.class; } return dataType; } @Override public boolean isCellEditable(int rowIndex, int mColIndex) { return false; } }; tcTable = new SortableJTable(new TableSorter(tcModel)) { public String getToolTipText(MouseEvent e) { Point p = e.getPoint(); int rowIndex = rowAtPoint(p); int colIndex = columnAtPoint(p); if (colIndex < 0) { return null; } return convertObjectToToolTip(getValueAt(rowIndex, colIndex)); } }; tcTable.setColumnSelectionAllowed(false); int tcWidth = interactive ? 360 : 480; int tcStatusWidth = 40; int tcTestbedWidth = 100; int tcDetailsWidth = 360; int tcResultWidth = 150; GUIConfiguration guiConfiguration = GUIConfiguration.getInstance(); List<?> list = guiConfiguration.configurationsAt(tableLayoutProperty); if (!list.isEmpty()) { try { tcWidth = guiConfiguration.getInt(testCaseColumnProperty); } catch (NoSuchElementException ex) { guiConfiguration.setProperty(testCaseColumnProperty, tcWidth); } try { tcStatusWidth = guiConfiguration.getInt(statusColumnProperty); } catch (NoSuchElementException ex) { guiConfiguration.setProperty(statusColumnProperty, tcStatusWidth); } try { tcDetailsWidth = guiConfiguration.getInt(detailsColumnProperty); } catch (NoSuchElementException ex) { guiConfiguration.setProperty(detailsColumnProperty, tcDetailsWidth); } try { tcTestbedWidth = guiConfiguration.getInt(testbedColumnProperty); } catch (NoSuchElementException ex) { guiConfiguration.setProperty(testbedColumnProperty, tcTestbedWidth); } if (interactive) { try { tcResultWidth = guiConfiguration.getInt(resultColumnProperty); } catch (NoSuchElementException ex) { guiConfiguration.setProperty(resultColumnProperty, tcResultWidth); } } } else { tcWidth = interactive ? 360 : 480; guiConfiguration.setProperty(testCaseColumnProperty, tcWidth); guiConfiguration.setProperty(statusColumnProperty, tcStatusWidth); guiConfiguration.setProperty(detailsColumnProperty, tcDetailsWidth); guiConfiguration.setProperty(testbedColumnProperty, tcTestbedWidth); if (interactive) { guiConfiguration.setProperty(resultColumnProperty, tcResultWidth); } try { guiConfiguration.save(); } catch (ConfigurationException ex) { logger.error("Error while saving GUI configuration: " + ex.getMessage()); } } TableColumnModel tcTableColumnModel = tcTable.getColumnModel(); tcTableColumnModel.getColumn(TEST_CASE).setPreferredWidth(tcWidth); tcTableColumnModel.getColumn(STATUS).setPreferredWidth(tcStatusWidth); tcTableColumnModel.getColumn(STATUS).setMaxWidth(40); tcTableColumnModel.getColumn(DETAILS).setPreferredWidth(tcDetailsWidth); tcTableColumnModel.getColumn(TESTBED).setPreferredWidth(tcTestbedWidth); tcTableColumnModel.getColumn(EXEC_TIME).setPreferredWidth(70); tcTableColumnModel.getColumn(EXEC_TIME).setMinWidth(70); tcTableColumnModel.getColumn(EXEC_TIME).setMaxWidth(70); tcTableColumnModel.removeColumn(tcTableColumnModel.getColumn(TC)); if (!interactive) { tcTable.getSelectionModel().addListSelectionListener(new TCResultsSelectionListeners()); } tcTable.setName("tcTable"); tcTableColumnModel.addColumnModelListener(new TableColumnModelListener() { public void columnAdded(TableColumnModelEvent e) { } public void columnRemoved(TableColumnModelEvent e) { } public void columnMoved(TableColumnModelEvent e) { } public void columnMarginChanged(ChangeEvent e) { try { // save the current layout int tcStatusWidth = tcTable.getColumnModel().getColumn(STATUS).getWidth(); int tcWidth = tcTable.getColumnModel().getColumn(TEST_CASE).getWidth(); int tcDetailsWidth = tcTable.getColumnModel().getColumn(DETAILS).getWidth(); int tcResultWidth = tcTable.getColumnModel().getColumn(RESULT).getWidth(); int tcTestbedWidth = tcTable.getColumnModel().getColumn(TESTBED).getWidth(); // save it into the settings GUIConfiguration guiConfiguration = GUIConfiguration.getInstance(); guiConfiguration.setProperty(statusColumnProperty, tcStatusWidth); guiConfiguration.setProperty(testCaseColumnProperty, tcWidth); guiConfiguration.setProperty(detailsColumnProperty, tcDetailsWidth); guiConfiguration.setProperty(testbedColumnProperty, tcTestbedWidth); if (interactive) { guiConfiguration.setProperty(resultColumnProperty, tcResultWidth); } guiConfiguration.save(); } catch (ConfigurationException ex) { logger.error("Error while saving GUI configuration: " + ex.getMessage()); } } public void columnSelectionChanged(ListSelectionEvent e) { } }); try { tcTable.setDefaultRenderer(Class.forName("java.lang.Object"), new TableCellRenderer()); } catch (ClassNotFoundException ex) { } if (interactive) { displayTableForInteractiveMode(); } else { displayTableForExecutionMode(); } tcTable.addMouseListener(new TableMouseListener()); // use timer for updating elapsed time every seconds timer.schedule(new TimerTask() { @Override public void run() { updateRunningTestCaseElapsedTime(); } }, 1000, 1000); }
From source file:pcgen.gui2.tabs.EquipInfoTab.java
private List<Integer> getMenuTargets(JTable table, MouseEvent e) { int row = table.rowAtPoint(e.getPoint()); if (!table.isRowSelected(row)) { table.setRowSelectionInterval(row, row); }/*from www.j av a2 s . co m*/ List<Integer> targets = new ArrayList<>(); for (int selRow : table.getSelectedRows()) { targets.add(selRow); } return targets; }
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 w w w . j a v a 2 s . co 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:org.eurocarbdb.application.glycoworkbench.plugin.PeakListChartPanel.java
public void mouseClicked(MouseEvent e) { // find peak under mouse current_peak = findPeakAt(e.getPoint()); if (MouseUtils.isSelectTrigger(e)) setSelection(current_peak);//from ww w. ja va2 s . c om else if (MouseUtils.isAddSelectTrigger(e)) addSelection(current_peak); else if (MouseUtils.isActionTrigger(e)) { setSelection(current_peak); onAnnotatePeaks(null); } }
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 ww w. j ava 2 s. com 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.eclipse.jubula.rc.swing.driver.RobotAwtImpl.java
/** * Checks if the mouse has to be moved on <code>p</code> or if the mouse * pointer already resides on this location. * @param p The point to move to//from w w w .j a v a2 s .co m * @return <code>true</code> if the mouse pointer resides on a different point, otherwise <code>false</code>. */ private boolean isMouseMoveRequired(Point p) { boolean result = true; Point point = m_mouseMotionTracker.getLastMousePointOnScreen(); if (point != null) { result = !point.equals(p); if (log.isDebugEnabled()) { MouseEvent event = (MouseEvent) m_mouseMotionTracker.getLastMouseMotionEvent(); if (event != null) { log.debug("Last mouse motion event point: " //$NON-NLS-1$ + event.getPoint()); } log.debug("Last converted screen point : " + point); //$NON-NLS-1$ log.debug("Required screen point : " + p); //$NON-NLS-1$ log.debug("Mouse move required? : " + result); //$NON-NLS-1$ } } return result; }
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(); }/*from w w w . jav a 2 s . com*/ 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; }