List of usage examples for java.awt.event MouseEvent getY
public int getY()
From source file:com.peterbochs.sourceleveldebugger.SourceLevelDebugger3.java
private void refreshCallGrapphButtonActionPerformed(ActionEvent evt) { graph = new mxGraph() { public void drawState(mxICanvas canvas, mxCellState state, String label) { if (getModel().isVertex(state.getCell()) && canvas instanceof PeterSwingCanvas) { PeterSwingCanvas c = (PeterSwingCanvas) canvas; c.drawVertex(state, label); } else { // draw edge, at least // super.drawState(canvas, state, label); super.drawState(canvas, state, true); }// w w w. j a v a2 s. c o m } // Ports are not used as terminals for edges, they are // only used to compute the graphical connection point public boolean isPort(Object cell) { mxGeometry geo = getCellGeometry(cell); return (geo != null) ? geo.isRelative() : false; } // Implements a tooltip that shows the actual // source and target of an edge public String getToolTipForCell(Object cell) { if (model.isEdge(cell)) { return convertValueToString(model.getTerminal(cell, true)) + " -> " + convertValueToString(model.getTerminal(cell, false)); } return super.getToolTipForCell(cell); } public boolean isCellFoldable(Object cell, boolean collapse) { return false; } }; graphComponent = new CallGraphComponent(graph); Object parent = graph.getDefaultParent(); // addCells(parent); graph.setCellsDisconnectable(false); graphComponent.setGridVisible(true); graphComponent.setGridColor(Color.lightGray); graphComponent.setBackground(Color.white); graphComponent.getViewport().setOpaque(false); graphComponent.setBackground(Color.WHITE); graphComponent.setConnectable(false); graphComponent.getGraphControl().addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { Object cell = graphComponent.getCellAt(e.getX(), e.getY()); if (cell != null) { String label = graph.getLabel(cell); if (label.contains("->")) { // cellClientEvent(label); } } } }); graph.setCellsResizable(false); graph.setCellsMovable(false); graph.setCellsEditable(false); graph.foldCells(false); graph.setGridSize(10); callGraphPanel.removeAll(); callGraphPanel.add(graphComponent, BorderLayout.CENTER); // mxGraphOutline graphOutline = new mxGraphOutline(graphComponent); // graphOutline.setBackground(Color.white); // graphOutline.setBorder(new LineBorder(Color.LIGHT_GRAY)); // callGraphPanel.removeAll(); // callGraphPanel.add(graphOutline, BorderLayout.CENTER); // callGraphPanel.setPreferredSize(new Dimension(100, 100)); }
From source file:net.sf.jabref.gui.FindUnlinkedFilesDialog.java
/** * Creates the tree view, that holds the data structure. <br> * <br>//from www .j a va 2 s . c om * Initially, the root node is <b>not</b> visible, so that the tree appears empty at the beginning. */ private void createTree() { /** * Mouse listener to listen for mouse events on the tree. <br> * This will mark the selected tree entry as "selected" or "unselected", * which will cause this nodes checkbox to appear as either "checked" or * "unchecked". */ treeMouseListener = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { int x = e.getX(); int y = e.getY(); int row = tree.getRowForLocation(x, y); TreePath path = tree.getPathForRow(row); if (path != null) { CheckableTreeNode node = (CheckableTreeNode) path.getLastPathComponent(); if (e.getClickCount() == 2) { Object userObject = node.getUserObject(); if ((userObject instanceof FileNodeWrapper) && node.isLeaf()) { FileNodeWrapper fnw = (FileNodeWrapper) userObject; try { JabRefDesktop.openExternalViewer( JabRefGUI.getMainFrame().getCurrentBasePanel().getBibDatabaseContext(), fnw.file.getAbsolutePath(), "pdf"); } catch (IOException e1) { LOGGER.info("Error opening file", e1); } } } else { node.check(); tree.invalidate(); tree.repaint(); } } } }; CheckableTreeNode startNode = new CheckableTreeNode("ROOT"); DefaultTreeModel model = new DefaultTreeModel(startNode); tree.setModel(model); tree.setRootVisible(false); DefaultTreeCellRenderer renderer = new CheckboxTreeCellRenderer(); tree.setCellRenderer(renderer); tree.addMouseListener(treeMouseListener); }
From source file:src.gui.ItTabbedPane.java
public void mousePressed(MouseEvent mouseEvent) {// this is for Linux if (mouseEvent.isPopupTrigger()) { //selectedTabIndex = indexAtLocation(mouseEvent.getX(), mouseEvent.getY()); // Only show for top row if (getTabPlacement() == JTabbedPane.TOP) { popupMenu.show(this, mouseEvent.getX(), mouseEvent.getY()); }//from ww w. j av a 2s . c om } }
From source file:src.gui.ItTabbedPane.java
public void mouseReleased(MouseEvent mouseEvent) {//this is for Windows if (mouseEvent.isPopupTrigger()) { // selectedTabIndex = indexAtLocation(mouseEvent.getX(), mouseEvent.getY()); // Only show for top row if (getTabPlacement() == JTabbedPane.TOP) { popupMenu.show(this, mouseEvent.getX(), mouseEvent.getY()); }/*from w w w . ja v a 2s. c o m*/ } }
From source file:com.mirth.connect.client.ui.dependencies.ChannelDependenciesPanel.java
private void initComponents() { setBackground(UIConstants.BACKGROUND_COLOR); dependencyLabel = new JLabel("This channel depends upon:"); dependencyTreeTable = new MirthTreeTable(); DefaultTreeTableModel dependencyModel = new SortableTreeTableModel(); DefaultMutableTreeTableNode dependencyRootNode = new DefaultMutableTreeTableNode(); dependencyModel.setRoot(dependencyRootNode); dependencyTreeTable.setTreeTableModel(dependencyModel); dependencyTreeTable.setRootVisible(false); dependencyTreeTable.setDoubleBuffered(true); dependencyTreeTable.setDragEnabled(false); dependencyTreeTable.setRowSelectionAllowed(true); dependencyTreeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); dependencyTreeTable.setRowHeight(UIConstants.ROW_HEIGHT); dependencyTreeTable.setFocusable(true); dependencyTreeTable.setOpaque(true); dependencyTreeTable.setEditable(false); dependencyTreeTable.setSortable(true); dependencyTreeTable.putClientProperty("JTree.lineStyle", "Horizontal"); dependencyTreeTable.setAutoCreateColumnsFromModel(false); dependencyTreeTable.setShowGrid(true, true); dependencyTreeTable.setTableHeader(null); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { dependencyTreeTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); }/* w w w . j ava 2s .co m*/ dependencyTreeTable.setTreeCellRenderer(new DependencyTreeCellRenderer(dependencyTreeTable)); dependencyTreeTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent evt) { checkSelection(evt); } @Override public void mouseReleased(MouseEvent evt) { checkSelection(evt); } private void checkSelection(MouseEvent evt) { if (dependencyTreeTable.rowAtPoint(new Point(evt.getX(), evt.getY())) < 0) { dependencyTreeTable.clearSelection(); } } }); dependencyTreeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { boolean removeEnabled = false; int[] rows = dependencyTreeTable.getSelectedModelRows(); if (rows.length == 1) { TreePath selectedPath = dependencyTreeTable.getPathForRow(rows[0]); if (selectedPath != null) { if (selectedPath.getPathCount() == 2) { removeEnabled = true; } } } dependencyRemoveButton.setEnabled(removeEnabled); } } }); dependencyScrollPane = new JScrollPane(dependencyTreeTable); dependencyExpandAllLabel = new JLabel("<html><u>Expand All</u></html>"); dependencyExpandAllLabel.setForeground(Color.BLUE); dependencyExpandAllLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); dependencyExpandAllLabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent evt) { dependencyTreeTable.expandAll(); } }); dependencyCollapseAllLabel = new JLabel("<html><u>Collapse All</u></html>"); dependencyCollapseAllLabel.setForeground(Color.BLUE); dependencyCollapseAllLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); dependencyCollapseAllLabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent evt) { dependencyTreeTable.collapseAll(); } }); dependencyAddButton = new JButton("Add"); dependencyAddButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { Map<String, String> allowedChannelsMap = getAllowedChannels(true); if (MapUtils.isNotEmpty(allowedChannelsMap)) { AddDialog dialog = new AddDialog(allowedChannelsMap, true); if (dialog.wasSaved()) { for (String dependencyId : dialog.getSelectedChannelIds()) { dependencies.add(new ChannelDependency(channel.getId(), dependencyId)); } updateTreeTable(true, dependencies); updateAddButton(); } } } }); dependencyRemoveButton = new JButton("Remove"); dependencyRemoveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int[] rows = dependencyTreeTable.getSelectedModelRows(); if (rows.length == 1) { TreePath selectedPath = dependencyTreeTable.getPathForRow(rows[0]); if (selectedPath != null && selectedPath.getPathCount() == 2) { Pair<String, String> pair = (Pair<String, String>) ((MutableTreeTableNode) selectedPath .getLastPathComponent()).getUserObject(); for (Iterator<ChannelDependency> it = dependencies.iterator(); it.hasNext();) { ChannelDependency dependency = it.next(); if (StringUtils.equals(channel.getId(), dependency.getDependentId()) && StringUtils.equals(pair.getLeft(), dependency.getDependencyId())) { it.remove(); } } updateTreeTable(true, dependencies); updateAddButton(); } } } }); dependencyRemoveButton.setEnabled(false); dependentLabel = new JLabel("This channel is depended upon by:"); dependentTreeTable = new MirthTreeTable(); DefaultTreeTableModel dependentModel = new SortableTreeTableModel(); DefaultMutableTreeTableNode dependentRootNode = new DefaultMutableTreeTableNode(); dependentModel.setRoot(dependentRootNode); dependentTreeTable.setTreeTableModel(dependentModel); dependentTreeTable.setRootVisible(false); dependentTreeTable.setDoubleBuffered(true); dependentTreeTable.setDragEnabled(false); dependentTreeTable.setRowSelectionAllowed(true); dependentTreeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); dependentTreeTable.setRowHeight(UIConstants.ROW_HEIGHT); dependentTreeTable.setFocusable(true); dependentTreeTable.setOpaque(true); dependentTreeTable.setEditable(false); dependentTreeTable.setSortable(true); dependentTreeTable.putClientProperty("JTree.lineStyle", "Horizontal"); dependentTreeTable.setAutoCreateColumnsFromModel(false); dependentTreeTable.setShowGrid(true, true); dependentTreeTable.setTableHeader(null); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { dependentTreeTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } dependentTreeTable.setTreeCellRenderer(new DependencyTreeCellRenderer(dependentTreeTable)); dependentTreeTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent evt) { checkSelection(evt); } @Override public void mouseReleased(MouseEvent evt) { checkSelection(evt); } private void checkSelection(MouseEvent evt) { if (dependentTreeTable.rowAtPoint(new Point(evt.getX(), evt.getY())) < 0) { dependentTreeTable.clearSelection(); } } }); dependentTreeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { boolean removeEnabled = false; int[] rows = dependentTreeTable.getSelectedModelRows(); if (rows.length == 1) { TreePath selectedPath = dependentTreeTable.getPathForRow(rows[0]); if (selectedPath != null) { if (selectedPath.getPathCount() == 2) { removeEnabled = true; } } } dependentRemoveButton.setEnabled(removeEnabled); } } }); dependentScrollPane = new JScrollPane(dependentTreeTable); dependentExpandAllLabel = new JLabel("<html><u>Expand All</u></html>"); dependentExpandAllLabel.setForeground(Color.BLUE); dependentExpandAllLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); dependentExpandAllLabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent evt) { dependentTreeTable.expandAll(); } }); dependentCollapseAllLabel = new JLabel("<html><u>Collapse All</u></html>"); dependentCollapseAllLabel.setForeground(Color.BLUE); dependentCollapseAllLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); dependentCollapseAllLabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent evt) { dependentTreeTable.collapseAll(); } }); dependentAddButton = new JButton("Add"); dependentAddButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { Map<String, String> allowedChannelsMap = getAllowedChannels(false); if (MapUtils.isNotEmpty(allowedChannelsMap)) { AddDialog dialog = new AddDialog(allowedChannelsMap, false); if (dialog.wasSaved()) { for (String dependentId : dialog.getSelectedChannelIds()) { dependencies.add(new ChannelDependency(dependentId, channel.getId())); } updateTreeTable(false, dependencies); updateAddButton(); } } } }); dependentRemoveButton = new JButton("Remove"); dependentRemoveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int[] rows = dependentTreeTable.getSelectedModelRows(); if (rows.length == 1) { TreePath selectedPath = dependentTreeTable.getPathForRow(rows[0]); if (selectedPath != null && selectedPath.getPathCount() == 2) { Pair<String, String> pair = (Pair<String, String>) ((MutableTreeTableNode) selectedPath .getLastPathComponent()).getUserObject(); for (Iterator<ChannelDependency> it = dependencies.iterator(); it.hasNext();) { ChannelDependency dependency = it.next(); if (StringUtils.equals(pair.getLeft(), dependency.getDependentId()) && StringUtils.equals(channel.getId(), dependency.getDependencyId())) { it.remove(); } } updateTreeTable(false, dependencies); updateAddButton(); } } } }); dependentRemoveButton.setEnabled(false); }
From source file:ome.formats.importer.gui.GuiImporter.java
/** * Check if the history table is enabled, disabling the history tab * if it is not./*from w w w . ja v a2 s . com*/ */ void checkHistoryEnable() { tPane.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { JTabbedPane pane = (JTabbedPane) e.getSource(); boolean userDisabled = config.getUserDisableHistory() | config.getStaticDisableHistory(); if (pane.indexAtLocation(e.getX(), e.getY()) == historyTabIndex && getHistoryTable().db.historyEnabled == false) { if (HistoryDB.alertOnce == false && !userDisabled) { JOptionPane.showMessageDialog(null, "For some reason we are not able to connect to the remote\n" + "history service (this most likely means the server does\n" + "not have this feature installed). In the meantime, you will\n" + "still be able to use the importer, however the history tab's\n" + "functionality will not be enabled.", "Warning", JOptionPane.ERROR_MESSAGE); HistoryDB.alertOnce = true; } } } }); }
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(); }// w w w . j a v a 2 s. c o 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:edu.purdue.cc.bionet.ui.GraphVisualizer.java
/** * The mouseClicked method of the MouseListener interface. * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) * /* w ww .ja v a2 s . c o m*/ * @param event The event which triggered this action. */ public void mouseClicked(MouseEvent event) { E edge = this.getPickSupport().getEdge(this.getGraphLayout(), event.getX(), event.getY()); V vertex = this.getPickSupport().getVertex(this.getGraphLayout(), event.getX(), event.getY()); if (edge != null && vertex == null) { this.fireGraphMouseEdgeClickedEvent(edge, event); } }
From source file:edu.purdue.cc.bionet.ui.GraphVisualizer.java
/** * The mousePressed method of the MouseListener interface. * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) * /*from www. j a v a2s. c o m*/ * @param event The event which triggered this action. */ public void mousePressed(MouseEvent event) { E edge = this.getPickSupport().getEdge(this.getGraphLayout(), event.getX(), event.getY()); V vertex = this.getPickSupport().getVertex(this.getGraphLayout(), event.getX(), event.getY()); if (edge != null && vertex == null) { this.fireGraphMouseEdgePressedEvent(edge, event); } }
From source file:edu.purdue.cc.bionet.ui.GraphVisualizer.java
/** * The mouseReleased method of the MouseListener interface. * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent) * // www . ja va2 s . c om * @param event The event which triggered this action. */ public void mouseReleased(MouseEvent event) { E edge = this.getPickSupport().getEdge(this.getGraphLayout(), event.getX(), event.getY()); V vertex = this.getPickSupport().getVertex(this.getGraphLayout(), event.getX(), event.getY()); if (edge != null && vertex == null) { this.fireGraphMouseEdgeReleasedEvent(edge, event); } }