List of usage examples for java.awt.event MouseEvent getSource
public Object getSource()
From source file:org.isatools.isacreator.optionselector.OptionGroup.java
public void mousePressed(MouseEvent mouseEvent) { if (mouseEvent.getSource() instanceof OptionItem) { OptionItem<T> item = (OptionItem<T>) mouseEvent.getSource(); if (item.isEnabled()) { if (singleSelection) { if (!item.getSelectedIcon()) { clearSelections();//from w ww. j a va 2 s . c o m item.setSelectedIcon(!item.getSelectedIcon()); fireItemSelectionEventToListeners(item); } } else { if (checkForSelectedItems(item)) { item.setSelectedIcon(!item.getSelectedIcon()); fireItemSelectionEventToListeners(item); } } } } }
From source file:org.zaproxy.zap.view.ComponentMaximiserMouseListener.java
/** * Calls {@link #triggerMaximisation(Component)} when clicked twice, with the source of the event as parameter. *//*from www. j a v a 2 s . c o m*/ @Override public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { triggerMaximisation((Component) evt.getSource()); } }
From source file:org.isatools.isacreator.visualization.AssayInfoPanel.java
public void mouseEntered(MouseEvent event) { if (event.getSource() instanceof JLabel) { JLabel lab = (JLabel) event.getSource(); lab.setForeground(UIHelper.LIGHT_GREEN_COLOR); }/*from www. j a va2 s. co m*/ }
From source file:org.isatools.isacreator.visualization.AssayInfoPanel.java
public void mouseExited(MouseEvent event) { if (event.getSource() instanceof JLabel) { JLabel lab = (JLabel) event.getSource(); lab.setForeground(UIHelper.DARK_GREEN_COLOR); }//from w w w . ja v a 2 s . co m }
From source file:net.panthema.BispanningGame.MyEditingGraphMousePlugin.java
public void mouseEntered(MouseEvent e) { JComponent c = (JComponent) e.getSource(); c.setCursor(cursor); }
From source file:net.panthema.BispanningGame.MyEditingGraphMousePlugin.java
public void mouseExited(MouseEvent e) { JComponent c = (JComponent) e.getSource(); c.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); }
From source file:edu.scripps.fl.pubchem.xmltool.gui.PubChemXMLExtractorGUI.java
public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 0) { if (e.getSource() == jtfFileXML) { if (jtfFileXML.getText().equals(aidText)) jtfFileXML.setText(""); }/*from w w w . ja va 2 s . c o m*/ if (e.getSource() == this) { if (jtfFileXML.getText().equals("")) jtfFileXML.setText(aidText); } } }
From source file:gui.ReEditingPopupGraphMousePlugin.java
@SuppressWarnings({ "unchecked", "serial" }) protected void handlePopup(MouseEvent e) { final VisualizationViewer<V, E> vv = (VisualizationViewer<V, E>) e.getSource(); final Layout<V, E> layout = vv.getGraphLayout(); final Graph<V, E> graph = layout.getGraph(); final Point2D p = e.getPoint(); final Point2D ivp = p; GraphElementAccessor<V, E> pickSupport = vv.getPickSupport(); if (pickSupport != null) { final V vertex = pickSupport.getVertex(layout, ivp.getX(), ivp.getY()); final E edge = pickSupport.getEdge(layout, ivp.getX(), ivp.getY()); final PickedState<V> pickedVertexState = vv.getPickedVertexState(); final PickedState<E> pickedEdgeState = vv.getPickedEdgeState(); if (vertex != null) { Set<V> picked = pickedVertexState.getPicked(); if (picked.size() > 0) { if (graph instanceof UndirectedGraph == false) { JMenu directedMenu = new JMenu("Create Directed Edge"); popup.add(directedMenu); for (final V other : picked) { directedMenu.add(new AbstractAction("[" + other + "," + vertex + "]") { public void actionPerformed(ActionEvent e) { graph.addEdge(edgeFactory.create(), other, vertex, EdgeType.DIRECTED); vv.repaint(); }/* w w w . j av a 2 s.c o m*/ }); } } if (graph instanceof DirectedGraph == false) { JMenu undirectedMenu = new JMenu("Create Undirected Edge"); popup.add(undirectedMenu); for (final V other : picked) { undirectedMenu.add(new AbstractAction("[" + other + "," + vertex + "]") { public void actionPerformed(ActionEvent e) { graph.addEdge(edgeFactory.create(), other, vertex); vv.repaint(); } }); } } } popup.add(new AbstractAction("Delete TETRA Vertex") { public void actionPerformed(ActionEvent e) { pickedVertexState.pick(vertex, false); graph.removeVertex(vertex); vv.repaint(); } }); } else if (edge != null) { popup.add(new AbstractAction("Delete Edge") { public void actionPerformed(ActionEvent e) { pickedEdgeState.pick(edge, false); graph.removeEdge(edge); vv.repaint(); } }); } else { popup.add(new AbstractAction("Create TETRA Vertex") { public void actionPerformed(ActionEvent e) { V newVertex = vertexFactory.create(); graph.addVertex(newVertex); layout.setLocation(newVertex, vv.getRenderContext().getMultiLayerTransformer().inverseTransform(p)); vv.repaint(); } }); } if (popup.getComponentCount() > 0) { popup.show(vv, e.getX(), e.getY()); } } }
From source file:org.isatools.isacreator.visualization.AssayInfoPanel.java
public void mousePressed(MouseEvent event) { if (event.getSource() == viewSwitch) { SwingUtilities.invokeLater(new Runnable() { public void run() { swappableContainer.removeAll(); if (viewSwitch.getText().equals(VIEW_INFO_TEXT)) { swappableContainer.add(prepareAssayInformation()); viewSwitch.setText(VIEW_VIZ_TEXT); nodeTypeSwitch.setVisible(false); } else { swappableContainer.add(prepareAssayTreatments()); viewSwitch.setText(VIEW_INFO_TEXT); nodeTypeSwitch.setVisible(true); }//from w ww.j a va 2s . c om swappableContainer.revalidate(); } }); } else if (event.getSource() == nodeTypeSwitch) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (tgv != null) { if (nodeTypeSwitch.getText().equals(VIEW_NODE_NAMES)) { tgv.setRenderer(TreatmentGroupViewer.RENDER_TEXT); nodeTypeSwitch.setText(HIDE_NODE_NAMES); } else { tgv.setRenderer(TreatmentGroupViewer.RENDER_CIRCLE); nodeTypeSwitch.setText(VIEW_NODE_NAMES); } } } }); } }
From source file:mulavito.gui.components.LayerDataPanel.java
public LayerDataPanel(FloatingTabbedPane owner) { super("Layer Data", owner); textArea = new JTextArea(defaultText); textArea.setEditable(false);//from w w w .j a v a 2s . c o m textArea.setCaretPosition(0); // Scroll up the text area. JScrollPane textPane = new JScrollPane(textArea); add(textPane, BorderLayout.CENTER); // updates the data mouseListener = new MouseAdapter() { @SuppressWarnings("unchecked") @Override public void mouseEntered(MouseEvent e) { if (e.getSource() instanceof LayerViewer<?, ?>) { LayerViewer<V, E> vv = (LayerViewer<V, E>) e.getSource(); showData(vv.getLayer()); } } @Override public void mouseExited(MouseEvent e) { showData(null); } }; // adds/removes focus listeners on layers graphPanelListener = new PropertyChangeListener() { @SuppressWarnings("unchecked") @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("Viewers")) { if (evt.getOldValue() instanceof LayerViewer<?, ?> && evt.getNewValue() == null) { // GraphPanel#removeLayer ((LayerViewer<?, ?>) evt.getOldValue()).removeMouseListener(mouseListener); } else if (evt.getOldValue() instanceof List<?>) { System.out.println("Replace"); for (LayerViewer<?, ?> vv : ((List<LayerViewer<?, ?>>) evt.getOldValue())) vv.removeMouseListener(mouseListener); } if (evt.getNewValue() instanceof LayerViewer<?, ?> && evt.getOldValue() == null) { // GraphPanel#addLayer ((LayerViewer<?, ?>) evt.getNewValue()).addMouseListener(mouseListener); } else if (evt.getNewValue() instanceof List<?>) { // New Layer List on start up for (LayerViewer<?, ?> vv : ((List<LayerViewer<?, ?>>) evt.getNewValue())) vv.addMouseListener(mouseListener); } showData(current); } } }; }