Java Code Examples for sun.awt.AWTAccessor#getMouseEventAccessor()
The following examples show how to use
sun.awt.AWTAccessor#getMouseEventAccessor() .
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: Autoscroller.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * ActionListener method. Invoked when the Timer fires. This will scroll * if necessary. */ @SuppressWarnings("deprecation") public void actionPerformed(ActionEvent x) { JComponent component = Autoscroller.component; if (component == null || !component.isShowing() || (event == null)) { _stop(component); return; } Point screenLocation = component.getLocationOnScreen(); MouseEvent e = new MouseEvent(component, event.getID(), event.getWhen(), event.getModifiers(), event.getX() - screenLocation.x, event.getY() - screenLocation.y, event.getXOnScreen(), event.getYOnScreen(), event.getClickCount(), event.isPopupTrigger(), MouseEvent.NOBUTTON); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(e, meAccessor.isCausedByTouchEvent(event)); component.superProcessMouseMotionEvent(e); }
Example 2
Source File: BasicComboPopup.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
protected MouseEvent convertMouseEvent( MouseEvent e ) { Point convertedPoint = SwingUtilities.convertPoint( (Component)e.getSource(), e.getPoint(), list ); MouseEvent newEvent = new MouseEvent( (Component)e.getSource(), e.getID(), e.getWhen(), e.getModifiers(), convertedPoint.x, convertedPoint.y, e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON ); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(newEvent, meAccessor.isCausedByTouchEvent(e)); return newEvent; }
Example 3
Source File: BasicComboPopup.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Creates the JList used in the popup to display * the items in the combo box model. This method is called when the UI class * is created. * * @return a <code>JList</code> used to display the combo box items */ protected JList createList() { return new JList( comboBox.getModel() ) { public void processMouseEvent(MouseEvent e) { if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) { // Fix for 4234053. Filter out the Control Key from the list. // ie., don't allow CTRL key deselection. Toolkit toolkit = Toolkit.getDefaultToolkit(); MouseEvent newEvent = new MouseEvent( (Component)e.getSource(), e.getID(), e.getWhen(), e.getModifiers() ^ toolkit.getMenuShortcutKeyMask(), e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(newEvent, meAccessor.isCausedByTouchEvent(e)); e = newEvent; } super.processMouseEvent(e); } }; }
Example 4
Source File: BasicComboPopup.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
protected MouseEvent convertMouseEvent( MouseEvent e ) { Point convertedPoint = SwingUtilities.convertPoint( (Component)e.getSource(), e.getPoint(), list ); MouseEvent newEvent = new MouseEvent( (Component)e.getSource(), e.getID(), e.getWhen(), e.getModifiers(), convertedPoint.x, convertedPoint.y, e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON ); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(newEvent, meAccessor.isCausedByTouchEvent(e)); return newEvent; }
Example 5
Source File: BasicComboPopup.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Converts mouse event. * * @param e a mouse event * @return converted mouse event */ protected MouseEvent convertMouseEvent( MouseEvent e ) { Point convertedPoint = SwingUtilities.convertPoint( (Component)e.getSource(), e.getPoint(), list ); @SuppressWarnings("deprecation") MouseEvent newEvent = new MouseEvent( (Component)e.getSource(), e.getID(), e.getWhen(), e.getModifiers(), convertedPoint.x, convertedPoint.y, e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON ); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(newEvent, meAccessor.isCausedByTouchEvent(e)); return newEvent; }
Example 6
Source File: BasicComboPopup.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
protected MouseEvent convertMouseEvent( MouseEvent e ) { Point convertedPoint = SwingUtilities.convertPoint( (Component)e.getSource(), e.getPoint(), list ); MouseEvent newEvent = new MouseEvent( (Component)e.getSource(), e.getID(), e.getWhen(), e.getModifiers(), convertedPoint.x, convertedPoint.y, e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON ); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(newEvent, meAccessor.isCausedByTouchEvent(e)); return newEvent; }
Example 7
Source File: MotifInternalFrameTitlePane.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
void forwardEventToParent(MouseEvent e) { MouseEvent newEvent = new MouseEvent( getParent(), e.getID(), e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(newEvent, meAccessor.isCausedByTouchEvent(e)); getParent().dispatchEvent(newEvent); }
Example 8
Source File: MotifInternalFrameTitlePane.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
void forwardEventToParent(MouseEvent e) { MouseEvent newEvent = new MouseEvent( getParent(), e.getID(), e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(newEvent, meAccessor.isCausedByTouchEvent(e)); getParent().dispatchEvent(newEvent); }
Example 9
Source File: Autoscroller.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Starts the timer targeting the passed in component. */ private void start(JComponent c, MouseEvent e) { Point screenLocation = c.getLocationOnScreen(); if (component != c) { _stop(component); } component = c; event = new MouseEvent(component, e.getID(), e.getWhen(), e.getModifiers(), e.getX() + screenLocation.x, e.getY() + screenLocation.y, e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(event, meAccessor.isCausedByTouchEvent(e)); if (timer == null) { timer = new Timer(100, this); } if (!timer.isRunning()) { timer.start(); } }
Example 10
Source File: MotifDesktopIconUI.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
void forwardEventToParent(MouseEvent e) { MouseEvent newEvent = new MouseEvent( getParent(), e.getID(), e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON ); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(newEvent, meAccessor.isCausedByTouchEvent(e)); getParent().dispatchEvent(newEvent); }
Example 11
Source File: Autoscroller.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Starts the timer targeting the passed in component. */ private void start(JComponent c, MouseEvent e) { Point screenLocation = c.getLocationOnScreen(); if (component != c) { _stop(component); } component = c; event = new MouseEvent(component, e.getID(), e.getWhen(), e.getModifiers(), e.getX() + screenLocation.x, e.getY() + screenLocation.y, e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(event, meAccessor.isCausedByTouchEvent(e)); if (timer == null) { timer = new Timer(100, this); } if (!timer.isRunning()) { timer.start(); } }
Example 12
Source File: MotifDesktopIconUI.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
void forwardEventToParent(MouseEvent e) { MouseEvent newEvent = new MouseEvent( getParent(), e.getID(), e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(newEvent, meAccessor.isCausedByTouchEvent(e)); getParent().dispatchEvent(newEvent); }
Example 13
Source File: MotifDesktopIconUI.java From Bytecoder with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") void forwardEventToParent(MouseEvent e) { MouseEvent newEvent = new MouseEvent( getParent(), e.getID(), e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(newEvent, meAccessor.isCausedByTouchEvent(e)); getParent().dispatchEvent(newEvent); }
Example 14
Source File: Autoscroller.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Starts the timer targeting the passed in component. */ private void start(JComponent c, MouseEvent e) { Point screenLocation = c.getLocationOnScreen(); if (component != c) { _stop(component); } component = c; event = new MouseEvent(component, e.getID(), e.getWhen(), e.getModifiers(), e.getX() + screenLocation.x, e.getY() + screenLocation.y, e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), MouseEvent.NOBUTTON); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(event, meAccessor.isCausedByTouchEvent(e)); if (timer == null) { timer = new Timer(100, this); } if (!timer.isRunning()) { timer.start(); } }
Example 15
Source File: JList.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Returns the tooltip text to be used for the given event. This overrides * {@code JComponent}'s {@code getToolTipText} to first check the cell * renderer component for the cell over which the event occurred, returning * its tooltip text, if any. This implementation allows you to specify * tooltip text on the cell level, by using {@code setToolTipText} on your * cell renderer component. * <p> * <strong>Note:</strong> For <code>JList</code> to properly display the * tooltips of its renderers in this manner, <code>JList</code> must be a * registered component with the <code>ToolTipManager</code>. This registration * is done automatically in the constructor. However, if at a later point * <code>JList</code> is unregistered, by way of a call to * {@code setToolTipText(null)}, tips from the renderers will no longer display. * * @param event the {@code MouseEvent} to fetch the tooltip text for * @see JComponent#setToolTipText * @see JComponent#getToolTipText */ public String getToolTipText(MouseEvent event) { if(event != null) { Point p = event.getPoint(); int index = locationToIndex(p); ListCellRenderer<? super E> r = getCellRenderer(); Rectangle cellBounds; if (index != -1 && r != null && (cellBounds = getCellBounds(index, index)) != null && cellBounds.contains(p.x, p.y)) { ListSelectionModel lsm = getSelectionModel(); Component rComponent = r.getListCellRendererComponent( this, getModel().getElementAt(index), index, lsm.isSelectedIndex(index), (hasFocus() && (lsm.getLeadSelectionIndex() == index))); if(rComponent instanceof JComponent) { MouseEvent newEvent; p.translate(-cellBounds.x, -cellBounds.y); newEvent = new MouseEvent(rComponent, event.getID(), event.getWhen(), event.getModifiers(), p.x, p.y, event.getXOnScreen(), event.getYOnScreen(), event.getClickCount(), event.isPopupTrigger(), MouseEvent.NOBUTTON); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(newEvent, meAccessor.isCausedByTouchEvent(event)); String tip = ((JComponent)rComponent).getToolTipText( newEvent); if (tip != null) { return tip; } } } } return super.getToolTipText(); }
Example 16
Source File: JTableHeader.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Allows the renderer's tips to be used if there is text set. * @param event the location of the event identifies the proper * renderer and, therefore, the proper tip * @return the tool tip for this component */ public String getToolTipText(MouseEvent event) { String tip = null; Point p = event.getPoint(); int column; // Locate the renderer under the event location if ((column = columnAtPoint(p)) != -1) { TableColumn aColumn = columnModel.getColumn(column); TableCellRenderer renderer = aColumn.getHeaderRenderer(); if (renderer == null) { renderer = defaultRenderer; } Component component = renderer.getTableCellRendererComponent( getTable(), aColumn.getHeaderValue(), false, false, -1, column); // Now have to see if the component is a JComponent before // getting the tip if (component instanceof JComponent) { // Convert the event to the renderer's coordinate system MouseEvent newEvent; Rectangle cellRect = getHeaderRect(column); p.translate(-cellRect.x, -cellRect.y); newEvent = new MouseEvent(component, event.getID(), event.getWhen(), event.getModifiers(), p.x, p.y, event.getXOnScreen(), event.getYOnScreen(), event.getClickCount(), event.isPopupTrigger(), MouseEvent.NOBUTTON); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(newEvent, meAccessor.isCausedByTouchEvent(event)); tip = ((JComponent)component).getToolTipText(newEvent); } } // No tip from the renderer get our own tip if (tip == null) tip = getToolTipText(); return tip; }
Example 17
Source File: FilePane.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public void mouseClicked(MouseEvent evt) { JComponent source = (JComponent)evt.getSource(); int index; if (source instanceof JList) { index = SwingUtilities2.loc2IndexFileList(list, evt.getPoint()); } else if (source instanceof JTable) { JTable table = (JTable)source; Point p = evt.getPoint(); index = table.rowAtPoint(p); boolean pointOutsidePrefSize = SwingUtilities2.pointOutsidePrefSize( table, index, table.columnAtPoint(p), p); if (pointOutsidePrefSize && !fullRowSelection) { return; } // Translate point from table to list if (index >= 0 && list != null && listSelectionModel.isSelectedIndex(index)) { // Make a new event with the list as source, placing the // click in the corresponding list cell. Rectangle r = list.getCellBounds(index, index); MouseEvent newEvent = new MouseEvent(list, evt.getID(), evt.getWhen(), evt.getModifiers(), r.x + 1, r.y + r.height/2, evt.getXOnScreen(), evt.getYOnScreen(), evt.getClickCount(), evt.isPopupTrigger(), evt.getButton()); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(newEvent, meAccessor.isCausedByTouchEvent(evt)); evt = newEvent; } } else { return; } if (index >= 0 && SwingUtilities.isLeftMouseButton(evt)) { JFileChooser fc = getFileChooser(); // For single click, we handle editing file name if (evt.getClickCount() == 1 && source instanceof JList) { if ((!fc.isMultiSelectionEnabled() || fc.getSelectedFiles().length <= 1) && index >= 0 && listSelectionModel.isSelectedIndex(index) && getEditIndex() == index && editFile == null) { editFileName(index); } else { if (index >= 0) { setEditIndex(index); } else { resetEditIndex(); } } } else if (evt.getClickCount() == 2) { // on double click (open or drill down one directory) be // sure to clear the edit index resetEditIndex(); } } // Forward event to Basic if (getDoubleClickListener() != null) { getDoubleClickListener().mouseClicked(evt); } }
Example 18
Source File: JList.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Returns the tooltip text to be used for the given event. This overrides * {@code JComponent}'s {@code getToolTipText} to first check the cell * renderer component for the cell over which the event occurred, returning * its tooltip text, if any. This implementation allows you to specify * tooltip text on the cell level, by using {@code setToolTipText} on your * cell renderer component. * <p> * <strong>Note:</strong> For <code>JList</code> to properly display the * tooltips of its renderers in this manner, <code>JList</code> must be a * registered component with the <code>ToolTipManager</code>. This registration * is done automatically in the constructor. However, if at a later point * <code>JList</code> is unregistered, by way of a call to * {@code setToolTipText(null)}, tips from the renderers will no longer display. * * @param event the {@code MouseEvent} to fetch the tooltip text for * @see JComponent#setToolTipText * @see JComponent#getToolTipText */ public String getToolTipText(MouseEvent event) { if(event != null) { Point p = event.getPoint(); int index = locationToIndex(p); ListCellRenderer<? super E> r = getCellRenderer(); Rectangle cellBounds; if (index != -1 && r != null && (cellBounds = getCellBounds(index, index)) != null && cellBounds.contains(p.x, p.y)) { ListSelectionModel lsm = getSelectionModel(); Component rComponent = r.getListCellRendererComponent( this, getModel().getElementAt(index), index, lsm.isSelectedIndex(index), (hasFocus() && (lsm.getLeadSelectionIndex() == index))); if(rComponent instanceof JComponent) { MouseEvent newEvent; p.translate(-cellBounds.x, -cellBounds.y); newEvent = new MouseEvent(rComponent, event.getID(), event.getWhen(), event.getModifiers(), p.x, p.y, event.getXOnScreen(), event.getYOnScreen(), event.getClickCount(), event.isPopupTrigger(), MouseEvent.NOBUTTON); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(newEvent, meAccessor.isCausedByTouchEvent(event)); String tip = ((JComponent)rComponent).getToolTipText( newEvent); if (tip != null) { return tip; } } } } return super.getToolTipText(); }
Example 19
Source File: JTableHeader.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** * Allows the renderer's tips to be used if there is text set. * @param event the location of the event identifies the proper * renderer and, therefore, the proper tip * @return the tool tip for this component */ public String getToolTipText(MouseEvent event) { String tip = null; Point p = event.getPoint(); int column; // Locate the renderer under the event location if ((column = columnAtPoint(p)) != -1) { TableColumn aColumn = columnModel.getColumn(column); TableCellRenderer renderer = aColumn.getHeaderRenderer(); if (renderer == null) { renderer = defaultRenderer; } Component component = renderer.getTableCellRendererComponent( getTable(), aColumn.getHeaderValue(), false, false, -1, column); // Now have to see if the component is a JComponent before // getting the tip if (component instanceof JComponent) { // Convert the event to the renderer's coordinate system MouseEvent newEvent; Rectangle cellRect = getHeaderRect(column); p.translate(-cellRect.x, -cellRect.y); newEvent = new MouseEvent(component, event.getID(), event.getWhen(), event.getModifiers(), p.x, p.y, event.getXOnScreen(), event.getYOnScreen(), event.getClickCount(), event.isPopupTrigger(), MouseEvent.NOBUTTON); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(newEvent, meAccessor.isCausedByTouchEvent(event)); tip = ((JComponent)component).getToolTipText(newEvent); } } // No tip from the renderer get our own tip if (tip == null) tip = getToolTipText(); return tip; }
Example 20
Source File: JTableHeader.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Allows the renderer's tips to be used if there is text set. * @param event the location of the event identifies the proper * renderer and, therefore, the proper tip * @return the tool tip for this component */ public String getToolTipText(MouseEvent event) { String tip = null; Point p = event.getPoint(); int column; // Locate the renderer under the event location if ((column = columnAtPoint(p)) != -1) { TableColumn aColumn = columnModel.getColumn(column); TableCellRenderer renderer = aColumn.getHeaderRenderer(); if (renderer == null) { renderer = defaultRenderer; } Component component = renderer.getTableCellRendererComponent( getTable(), aColumn.getHeaderValue(), false, false, -1, column); // Now have to see if the component is a JComponent before // getting the tip if (component instanceof JComponent) { // Convert the event to the renderer's coordinate system MouseEvent newEvent; Rectangle cellRect = getHeaderRect(column); p.translate(-cellRect.x, -cellRect.y); newEvent = new MouseEvent(component, event.getID(), event.getWhen(), event.getModifiers(), p.x, p.y, event.getXOnScreen(), event.getYOnScreen(), event.getClickCount(), event.isPopupTrigger(), MouseEvent.NOBUTTON); MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor(); meAccessor.setCausedByTouchEvent(newEvent, meAccessor.isCausedByTouchEvent(event)); tip = ((JComponent)component).getToolTipText(newEvent); } } // No tip from the renderer get our own tip if (tip == null) tip = getToolTipText(); return tip; }