Java Code Examples for java.awt.Component#addMouseListener()
The following examples show how to use
java.awt.Component#addMouseListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XDataViewer.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public static void registerForMouseEvent(Component comp, MouseListener mouseListener) { if(comp instanceof JScrollPane) { JScrollPane pane = (JScrollPane) comp; comp = pane.getViewport().getView(); } if(comp instanceof Container) { Container container = (Container) comp; Component[] components = container.getComponents(); for(int i = 0; i < components.length; i++) { registerForMouseEvent(components[i], mouseListener); } } //No registration for XOpenTypedata that are themselves clickable. //No registration for JButton that are themselves clickable. if(comp != null && (!(comp instanceof XOpenTypeViewer.XOpenTypeData) && !(comp instanceof JButton)) ) comp.addMouseListener(mouseListener); }
Example 2
Source File: XDataViewer.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void registerForMouseEvent(Component comp, MouseListener mouseListener) { if(comp instanceof JScrollPane) { JScrollPane pane = (JScrollPane) comp; comp = pane.getViewport().getView(); } if(comp instanceof Container) { Container container = (Container) comp; Component[] components = container.getComponents(); for(int i = 0; i < components.length; i++) { registerForMouseEvent(components[i], mouseListener); } } //No registration for XOpenTypedata that are themselves clickable. //No registration for JButton that are themselves clickable. if(comp != null && (!(comp instanceof XOpenTypeViewer.XOpenTypeData) && !(comp instanceof JButton)) ) comp.addMouseListener(mouseListener); }
Example 3
Source File: ContextMenuManager.java From pdfxtk with Apache License 2.0 | 6 votes |
private void setupML(Component cmp, boolean add) { if(cmp instanceof Container) { Component[] cmps = ((Container)cmp).getComponents(); for(int i = 0; i < cmps.length; i++) if(cmps[i] instanceof Component) setupML(cmps[i], add); } else if(cmp instanceof JScrollPane) { if(((JScrollPane)cmp).getViewport().getView() instanceof Component) setupML(((JScrollPane)cmp).getViewport().getView(), add); return; } if(add) cmp.addMouseListener(this); else cmp.removeMouseListener(this); }
Example 4
Source File: XDataViewer.java From visualvm with GNU General Public License v2.0 | 6 votes |
public static void registerForMouseEvent(Component comp, MouseListener mouseListener) { if(comp instanceof JScrollPane) { JScrollPane pane = (JScrollPane) comp; comp = pane.getViewport().getView(); } if(comp instanceof Container) { Container container = (Container) comp; Component[] components = container.getComponents(); for(int i = 0; i < components.length; i++) { registerForMouseEvent(components[i], mouseListener); } } //No registration for XOpenTypedata that are themselves clickable. //No registration for JButton that are themselves clickable. if(comp != null && (!(comp instanceof XOpenTypeViewer.XOpenTypeData) && !(comp instanceof JButton)) ) comp.addMouseListener(mouseListener); }
Example 5
Source File: XDataViewer.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void registerForMouseEvent(Component comp, MouseListener mouseListener) { if(comp instanceof JScrollPane) { JScrollPane pane = (JScrollPane) comp; comp = pane.getViewport().getView(); } if(comp instanceof Container) { Container container = (Container) comp; Component[] components = container.getComponents(); for(int i = 0; i < components.length; i++) { registerForMouseEvent(components[i], mouseListener); } } //No registration for XOpenTypedata that are themselves clickable. //No registration for JButton that are themselves clickable. if(comp != null && (!(comp instanceof XOpenTypeViewer.XOpenTypeData) && !(comp instanceof JButton)) ) comp.addMouseListener(mouseListener); }
Example 6
Source File: XDataViewer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public static void registerForMouseEvent(Component comp, MouseListener mouseListener) { if(comp instanceof JScrollPane) { JScrollPane pane = (JScrollPane) comp; comp = pane.getViewport().getView(); } if(comp instanceof Container) { Container container = (Container) comp; Component[] components = container.getComponents(); for(int i = 0; i < components.length; i++) { registerForMouseEvent(components[i], mouseListener); } } //No registration for XOpenTypedata that are themselves clickable. //No registration for JButton that are themselves clickable. if(comp != null && (!(comp instanceof XOpenTypeViewer.XOpenTypeData) && !(comp instanceof JButton)) ) comp.addMouseListener(mouseListener); }
Example 7
Source File: XDataViewer.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void registerForMouseEvent(Component comp, MouseListener mouseListener) { if(comp instanceof JScrollPane) { JScrollPane pane = (JScrollPane) comp; comp = pane.getViewport().getView(); } if(comp instanceof Container) { Container container = (Container) comp; Component[] components = container.getComponents(); for(int i = 0; i < components.length; i++) { registerForMouseEvent(components[i], mouseListener); } } //No registration for XOpenTypedata that are themselves clickable. //No registration for JButton that are themselves clickable. if(comp != null && (!(comp instanceof XOpenTypeViewer.XOpenTypeData) && !(comp instanceof JButton)) ) comp.addMouseListener(mouseListener); }
Example 8
Source File: XDataViewer.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void registerForMouseEvent(Component comp, MouseListener mouseListener) { if(comp instanceof JScrollPane) { JScrollPane pane = (JScrollPane) comp; comp = pane.getViewport().getView(); } if(comp instanceof Container) { Container container = (Container) comp; Component[] components = container.getComponents(); for(int i = 0; i < components.length; i++) { registerForMouseEvent(components[i], mouseListener); } } //No registration for XOpenTypedata that are themselves clickable. //No registration for JButton that are themselves clickable. if(comp != null && (!(comp instanceof XOpenTypeViewer.XOpenTypeData) && !(comp instanceof JButton)) ) comp.addMouseListener(mouseListener); }
Example 9
Source File: XDataViewer.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void registerForMouseEvent(Component comp, MouseListener mouseListener) { if(comp instanceof JScrollPane) { JScrollPane pane = (JScrollPane) comp; comp = pane.getViewport().getView(); } if(comp instanceof Container) { Container container = (Container) comp; Component[] components = container.getComponents(); for(int i = 0; i < components.length; i++) { registerForMouseEvent(components[i], mouseListener); } } //No registration for XOpenTypedata that are themselves clickable. //No registration for JButton that are themselves clickable. if(comp != null && (!(comp instanceof XOpenTypeViewer.XOpenTypeData) && !(comp instanceof JButton)) ) comp.addMouseListener(mouseListener); }
Example 10
Source File: XDataViewer.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public static void registerForMouseEvent(Component comp, MouseListener mouseListener) { if(comp instanceof JScrollPane) { JScrollPane pane = (JScrollPane) comp; comp = pane.getViewport().getView(); } if(comp instanceof Container) { Container container = (Container) comp; Component[] components = container.getComponents(); for(int i = 0; i < components.length; i++) { registerForMouseEvent(components[i], mouseListener); } } //No registration for XOpenTypedata that are themselves clickable. //No registration for JButton that are themselves clickable. if(comp != null && (!(comp instanceof XOpenTypeViewer.XOpenTypeData) && !(comp instanceof JButton)) ) comp.addMouseListener(mouseListener); }
Example 11
Source File: BalloonManager.java From netbeans with Apache License 2.0 | 5 votes |
private void handleMouseOver( Container c, MouseListener ml ) { c.addMouseListener(ml); for( Component child : c.getComponents() ) { child.addMouseListener(ml); if( child instanceof Container ) handleMouseOver((Container)child, ml); } }
Example 12
Source File: BalloonManager.java From netbeans with Apache License 2.0 | 5 votes |
private void handleMouseOver( Container c, MouseListener ml ) { c.addMouseListener(ml); for( Component child : c.getComponents() ) { child.addMouseListener(ml); if( child instanceof Container ) handleMouseOver((Container)child, ml); } }
Example 13
Source File: SplayedLayout.java From pumpernickel with MIT License | 5 votes |
private void addListeners(Component c) { if (!Arrays.asList(c.getMouseListeners()).contains(mouseListener)) c.addMouseListener(mouseListener); if (!Arrays.asList(c.getFocusListeners()).contains(focusListener)) c.addFocusListener(focusListener); if (c instanceof Container) { Container c2 = (Container) c; for (int a = 0; a < c2.getComponentCount(); a++) { addListeners(c2.getComponent(a)); } } }
Example 14
Source File: GOSwingEventConverter.java From settlers-remake with MIT License | 5 votes |
/** * Creates a new event converter, that converts swing events to go events. * * @param component * The component. * @param provider * THe provider to which to send the events. */ public GOSwingEventConverter(Component component, GOEventHandlerProvider provider) { super(provider); component.setFocusTraversalKeysEnabled(false); component.addKeyListener(this); component.addMouseListener(this); component.addMouseMotionListener(this); component.addMouseWheelListener(this); component.addHierarchyListener(this); addReplaceRule(new EventReplacementRule(ReplacableEvent.DRAW, Replacement.COMMAND_SELECT, MOUSE_TIME_TRSHOLD, MOUSE_MOVE_TRESHOLD)); addReplaceRule(new EventReplacementRule(ReplacableEvent.PAN, Replacement.COMMAND_ACTION, MOUSE_TIME_TRSHOLD, MOUSE_MOVE_TRESHOLD)); }
Example 15
Source File: DescendantMouseListener.java From pumpernickel with MIT License | 5 votes |
/** * Add all our internal listeners from a component and its descendants. */ private void addListeners(DefaultMutableTreeNode componentNode) { Component c = (Component) componentNode.getUserObject(); c.addHierarchyListener(hierarchyListener); c.addMouseListener(mouseListener); c.addMouseMotionListener(mouseListener); for (int a = 0; a < componentNode.getChildCount(); a++) { addListeners((DefaultMutableTreeNode) componentNode.getChildAt(a)); } if (c instanceof Container) ((Container) c).addContainerListener(containerListener); }
Example 16
Source File: JPEGsNotAcceleratedTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private static void showRes(String desc, final BufferedImage src) { final int w = src.getWidth(); final int h = src.getHeight(); Frame f = new Frame(desc+": dbl-click to exit"); Component c; f.add(c = new Component() { public Dimension getPreferredSize() { return new Dimension(w,h); } public void paint(Graphics g) { g.clearRect(0, 0, getWidth(), getHeight()); g.drawImage(src, 0,0, null); } }); c.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) { System.exit(0); } } }); f.pack(); synchronized (JPEGsNotAcceleratedTest.class) { f.setLocation(frameX, frameY); frameX += f.getWidth(); if ((frameX + f.getWidth()) > f.getGraphicsConfiguration().getBounds().width) { frameY += TEST_H; if ((frameY + f.getHeight()) > f.getGraphicsConfiguration().getBounds().height) { startY += 30; startX += 30; frameY = startY; } frameX = startX; } }; f.setVisible(true); }
Example 17
Source File: ParentButtonPanel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
@Override public Component add(Component c) { Component result = super.add(c); c.addMouseListener(borderListener); return result; }
Example 18
Source File: ComponentMover.java From mars-sim with GNU General Public License v3.0 | 4 votes |
/** * Add the required listeners to the specified component * * @param component the component the listeners are added to */ public void registerComponent(Component... components) { for (Component component : components) component.addMouseListener(this); }
Example 19
Source File: GlobalMouseAdapter.java From jclic with GNU General Public License v2.0 | 4 votes |
public void attachTo(Component cmp, boolean catchMotion) { cmp.addMouseListener(this); if (catchMotion) cmp.addMouseMotionListener(this); }
Example 20
Source File: ComponentMover.java From SikuliX1 with MIT License | 3 votes |
/** * Add the required listeners to the specified component * * @param components components the listeners are added to */ public void registerComponent(Component... components) { for (Component component : components) component.addMouseListener( this ); }