Class FlatRadioButtonUI.AWTPeerMouseExitedFix

  • All Implemented Interfaces:
    java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.beans.PropertyChangeListener, java.util.EventListener
    Enclosing class:
    FlatRadioButtonUI

    private static class FlatRadioButtonUI.AWTPeerMouseExitedFix
    extends java.awt.event.MouseAdapter
    implements java.beans.PropertyChangeListener
    Hack for missing mouse-exited event for java.awt.Checkbox on macOS (to fix hover effect). On macOS, AWT components internally use Swing components. This is implemented in class sun.lwawt.LWCheckboxPeer, which uses a container component CheckboxDelegate that has a JCheckBox and a JRadioButton as children. Only one of them is visible. The reason that mouse-exited event is not sent to the JCheckBox or JRadioButton is that sun.lwawt.LWComponentPeer.createDelegateEvent() uses SwingUtilities.getDeepestComponentAt() to find the event target, which finds the container component CheckboxDelegate, which receives the mouse-exited event. This class adds listeners and forwards the mouse-exited event from CheckboxDelegate to JCheckBox or JRadioButton.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private javax.swing.JComponent button  
    • Constructor Summary

      Constructors 
      Constructor Description
      AWTPeerMouseExitedFix​(javax.swing.JComponent button)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static void install​(javax.swing.JComponent button)  
      void mouseExited​(java.awt.event.MouseEvent e)  
      void propertyChange​(java.beans.PropertyChangeEvent e)  
      (package private) static void uninstall​(javax.swing.JComponent button)  
      • Methods inherited from class java.awt.event.MouseAdapter

        mouseClicked, mouseDragged, mouseEntered, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • button

        private final javax.swing.JComponent button
    • Constructor Detail

      • AWTPeerMouseExitedFix

        AWTPeerMouseExitedFix​(javax.swing.JComponent button)
    • Method Detail

      • install

        static void install​(javax.swing.JComponent button)
      • uninstall

        static void uninstall​(javax.swing.JComponent button)
      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent e)
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener
      • mouseExited

        public void mouseExited​(java.awt.event.MouseEvent e)
        Specified by:
        mouseExited in interface java.awt.event.MouseListener
        Overrides:
        mouseExited in class java.awt.event.MouseAdapter