List of usage examples for java.awt.event MouseEvent MouseEvent
public MouseEvent(Component source, int id, long when, int modifiers, int x, int y, int clickCount, boolean popupTrigger)
From source file:Main.java
public static MouseEvent newMouseEvent(Component comp, int id, MouseEvent e) { return new MouseEvent(comp, id, e.getWhen(), e.getModifiers() | e.getModifiersEx(), e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger()); }
From source file:com.limegroup.gnutella.gui.tables.ActionIconAndNameEditor.java
public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, int row, int column) { ActionIconAndNameHolder in = (ActionIconAndNameHolder) value; action = in.getAction();/*from w w w. j a v a2 s . com*/ final Component component = new ActionIconAndNameRenderer().getTableCellRendererComponent(table, value, isSelected, true, row, column); component.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (actionRegion == null) { component_mousePressed(e); } else { if (actionRegion.contains(e.getPoint())) { component_mousePressed(e); } else { if (e.getClickCount() >= 2) { Toolkit.getDefaultToolkit().getSystemEventQueue() .postEvent(new MouseEvent(table, MouseEvent.MOUSE_CLICKED, e.getWhen(), e.getModifiers(), component.getX() + e.getX(), component.getY() + e.getY(), e.getClickCount(), false)); } } } } else if (e.getButton() == MouseEvent.BUTTON3) { Toolkit.getDefaultToolkit().getSystemEventQueue() .postEvent(new MouseEvent(table, e.getID(), e.getWhen(), e.getModifiers(), component.getX() + e.getX(), component.getY() + e.getY(), e.getClickCount(), true)); } } }); return component; }
From source file:edu.umn.ecology.populus.plot.BasicPlotCanvas.java
/** The popup menu on the output screen accesses this function to dynamically modify the graph. When "optimized," the case values should be turned into constants somewhere for easier modification.*///from ww w . jav a 2 s. c o m public void displayChartOptionScreen(int whatOption) { if (PopPreferencesStorage.isUseJFreeClass()) { //TODO } else { JCAxis h = chart.getChartArea().getHorizActionAxis(); JCAxis v = chart.getChartArea().getVertActionAxis(); switch (whatOption) { case MenuOptions.kCoarserGrid: coarserGrid(); break; case MenuOptions.kFinerGrid: finerGrid(); break; case MenuOptions.kClearGrid: h.setGridVisible(false); v.setGridVisible(false); break; case MenuOptions.kOptionScreen: /*this is kind of a "hacked" way of bringing up the customizer screen because unfortunately, the JClass people didn't provide an easier way to do this. but this works, so whatever.*/ chart.mousePressed(new MouseEvent(this, MouseEvent.MOUSE_PRESSED, System.currentTimeMillis(), InputEvent.SHIFT_MASK, 0, 0, 1, false)); break; case MenuOptions.kReset: h.setGridVisible(false); v.setGridVisible(false); chart.reset(); break; } } }
From source file:it.unibas.spicygui.vista.listener.MyMouseEventListener.java
private void dispacciaEvento(Component com, MouseEvent e, Point point, boolean draggedEvent) { if (com == null) { com = SwingUtilities.getDeepestComponentAt(pannelloPrincipale, point.x, point.y); }/* www. j a v a2 s . c o m*/ Point componentPoint = SwingUtilities.convertPoint(component, e.getPoint(), com); if (com != null) { if (com instanceof JTree) { TreePath treePath = ((JTree) com).getPathForLocation(componentPoint.x, componentPoint.y); if (treePath == null || draggedEvent) { jLayeredPane.moveToFront(component); component.updateUI(); if (e.getButton() == MouseEvent.BUTTON3) { return; } } } com.dispatchEvent(new MouseEvent(com, e.getID(), e.getWhen(), e.getModifiers(), componentPoint.x, componentPoint.y, e.getClickCount(), e.isPopupTrigger())); jLayeredPane.moveToFront(component); component.updateUI(); } jLayeredPane.moveToFront(component); component.updateUI(); }
From source file:dbseer.gui.panel.DBSeerSelectableChartPanel.java
@Override public void mousePressed(MouseEvent e) { super.mousePressed(e); Rectangle2D origArea = this.getScreenDataArea(); Plot plot = chart.getPlot();//w ww. j a v a 2s . c om if (!(plot instanceof XYPlot)) { return; } XYPlot xyPlot = chart.getXYPlot(); String origDomainAxisLabel = xyPlot.getDomainAxis().getLabel(); if (SwingUtilities.isRightMouseButton(e)) { return; } for (DBSeerSelectableChartPanel panel : DBSeerPlotPresetFrame.chartPanels) { if (panel != this) { Plot otherPlot = panel.getChart().getPlot(); if (!(otherPlot instanceof XYPlot)) { continue; } Rectangle2D otherArea = panel.getScreenDataArea(); XYPlot otherXYPlot = panel.getChart().getXYPlot(); String otherDomainAxisLabel = otherXYPlot.getDomainAxis().getLabel(); if (origDomainAxisLabel.equalsIgnoreCase(otherDomainAxisLabel)) { double origRangeX = origArea.getMaxX() - origArea.getMinX(); double origRangeY = origArea.getMaxY() - origArea.getMinY(); double otherRangeX = otherArea.getMaxX() - otherArea.getMinX(); double otherRangeY = otherArea.getMaxY() - otherArea.getMinY(); double syncX = otherArea.getMinX() + (e.getX() - origArea.getMinX()) / origRangeX * otherRangeX; double syncY = otherArea.getMinY() + (e.getY() - origArea.getMinY()) / origRangeY * otherRangeY; MouseEvent syncEvent = new MouseEvent(this, 0, 0, 0, (int) syncX, (int) syncY, 1, false); panel.syncMousePressed(syncEvent); } } } }
From source file:it.unibas.spicygui.vista.listener.MyMouseEventListener.java
private void dispacciaEventoDrag(Component com, MouseEvent e, Point point, boolean draggedEvent) { Point componentPoint = SwingUtilities.convertPoint(component, e.getPoint(), com); if (com != null) { if (com instanceof JTree) { TreePath treePath = ((JTree) com).getPathForLocation(componentPoint.x, componentPoint.y); if (treePath == null || draggedEvent) { component.updateUI();/*from ww w . j a v a 2 s .com*/ return; } } if ((!(com instanceof JScrollBar) && (tmp12 instanceof JScrollBar))) { jLayeredPane.moveToFront(component); component.updateUI(); return; } com.dispatchEvent(new MouseEvent(component, e.getID(), e.getWhen(), e.getModifiers(), componentPoint.x, componentPoint.y, e.getClickCount(), e.isPopupTrigger())); jLayeredPane.moveToFront(component); component.updateUI(); } jLayeredPane.moveToFront(component); component.updateUI(); }
From source file:components.GlassPaneDemo.java
private void redispatchMouseEvent(MouseEvent e, boolean repaint) { Point glassPanePoint = e.getPoint(); Container container = contentPane; Point containerPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, contentPane); if (containerPoint.y < 0) { //we're not in the content pane if (containerPoint.y + menuBar.getHeight() >= 0) { //The mouse event is over the menu bar. //Could handle specially. } else {/* w w w .ja v a 2 s. c o m*/ //The mouse event is over non-system window //decorations, such as the ones provided by //the Java look and feel. //Could handle specially. } } else { //The mouse event is probably over the content pane. //Find out exactly which component it's over. Component component = SwingUtilities.getDeepestComponentAt(container, containerPoint.x, containerPoint.y); if ((component != null) && (component.equals(liveButton))) { //Forward events over the check box. Point componentPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, component); component.dispatchEvent(new MouseEvent(component, e.getID(), e.getWhen(), e.getModifiers(), componentPoint.x, componentPoint.y, e.getClickCount(), e.isPopupTrigger())); } } //Update the glass pane if requested. if (repaint) { glassPane.setPoint(glassPanePoint); glassPane.repaint(); } }
From source file:GlassPaneDemo.java
private void redispatchMouseEvent(MouseEvent e, boolean repaint) { Point glassPanePoint = e.getPoint(); Container container = contentPane; Point containerPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, contentPane); if (containerPoint.y < 0) { // we're not in the content pane if (containerPoint.y + menuBar.getHeight() >= 0) { // The mouse event is over the menu bar. // Could handle specially. } else {//from www. ja va 2s. c o m // The mouse event is over non-system window // decorations, such as the ones provided by // the Java look and feel. // Could handle specially. } } else { // The mouse event is probably over the content pane. // Find out exactly which component it's over. Component component = SwingUtilities.getDeepestComponentAt(container, containerPoint.x, containerPoint.y); if ((component != null) && (component.equals(liveButton))) { // Forward events over the check box. Point componentPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, component); component.dispatchEvent(new MouseEvent(component, e.getID(), e.getWhen(), e.getModifiers(), componentPoint.x, componentPoint.y, e.getClickCount(), e.isPopupTrigger())); } } // Update the glass pane if requested. if (repaint) { glassPane.setPoint(glassPanePoint); glassPane.repaint(); } }
From source file:dbseer.gui.panel.DBSeerSelectableChartPanel.java
@Override public void mouseDragged(MouseEvent e) { super.mouseDragged(e); Rectangle2D origArea = this.getScreenDataArea(); Plot plot = chart.getPlot();//from w w w . ja va 2 s. com if (!(plot instanceof XYPlot)) { return; } XYPlot xyPlot = chart.getXYPlot(); String origDomainAxisLabel = xyPlot.getDomainAxis().getLabel(); if (SwingUtilities.isRightMouseButton(e)) { return; } for (DBSeerSelectableChartPanel panel : DBSeerPlotPresetFrame.chartPanels) { if (panel != this) { Plot otherPlot = panel.getChart().getPlot(); if (!(otherPlot instanceof XYPlot)) { continue; } Rectangle2D otherArea = panel.getScreenDataArea(); XYPlot otherXYPlot = panel.getChart().getXYPlot(); String otherDomainAxisLabel = otherXYPlot.getDomainAxis().getLabel(); if (origDomainAxisLabel.equalsIgnoreCase(otherDomainAxisLabel)) { double origRangeX = origArea.getMaxX() - origArea.getMinX(); double origRangeY = origArea.getMaxY() - origArea.getMinY(); double otherRangeX = otherArea.getMaxX() - otherArea.getMinX(); double otherRangeY = otherArea.getMaxY() - otherArea.getMinY(); double syncX = otherArea.getMinX() + (e.getX() - origArea.getMinX()) / origRangeX * otherRangeX; double syncY = otherArea.getMinY() + (e.getY() - origArea.getMinY()) / origRangeY * otherRangeY; MouseEvent syncEvent = new MouseEvent(this, 0, 0, 0, (int) syncX, (int) syncY, 1, false); panel.syncMouseDragged(syncEvent); } } } }
From source file:dbseer.gui.panel.DBSeerSelectableChartPanel.java
@Override public void mouseReleased(MouseEvent e) { super.mouseReleased(e); Rectangle2D origArea = this.getScreenDataArea(); Plot plot = chart.getPlot();/*from w w w . ja va 2 s. c o m*/ if (!(plot instanceof XYPlot)) { return; } XYPlot xyPlot = chart.getXYPlot(); String origDomainAxisLabel = xyPlot.getDomainAxis().getLabel(); if (SwingUtilities.isRightMouseButton(e)) { return; } for (DBSeerSelectableChartPanel panel : DBSeerPlotPresetFrame.chartPanels) { if (panel != this) { Plot otherPlot = panel.getChart().getPlot(); if (!(otherPlot instanceof XYPlot)) { continue; } Rectangle2D otherArea = panel.getScreenDataArea(); XYPlot otherXYPlot = panel.getChart().getXYPlot(); String otherDomainAxisLabel = otherXYPlot.getDomainAxis().getLabel(); if (origDomainAxisLabel.equalsIgnoreCase(otherDomainAxisLabel)) { double origRangeX = origArea.getMaxX() - origArea.getMinX(); double origRangeY = origArea.getMaxY() - origArea.getMinY(); double otherRangeX = otherArea.getMaxX() - otherArea.getMinX(); double otherRangeY = otherArea.getMaxY() - otherArea.getMinY(); double syncX = otherArea.getMinX() + (e.getX() - origArea.getMinX()) / origRangeX * otherRangeX; double syncY = otherArea.getMinY() + (e.getY() - origArea.getMinY()) / origRangeY * otherRangeY; MouseEvent syncEvent = new MouseEvent(this, 0, 0, 0, (int) syncX, (int) syncY, 1, false); panel.syncMouseReleased(syncEvent); } } } }