org.jdesktop.jxlayer.plaf.ext
Class MouseScrollableUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by org.jdesktop.jxlayer.plaf.LayerUI<V>
          extended by org.jdesktop.jxlayer.plaf.AbstractLayerUI<javax.swing.JScrollPane>
              extended by org.jdesktop.jxlayer.plaf.ext.MouseScrollableUI
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.util.EventListener

public class MouseScrollableUI
extends AbstractLayerUI<javax.swing.JScrollPane>
implements java.awt.event.ActionListener

The MouseScrollableUI provides the mouse auto-scrolling feature for your applications. Wrap your JScrollPane with a JXLayer, set an instance of MouseScrollableUI as the JXLayer's ui and after that, pressing the middle mouse button inside the JScrollPane will activate the auto-scrolling mode.

Here is an example of using MouseScrollableUI:

 // a JScrollPane to be enhanced with mouse auto-scrolling
 JScrollPane myScrollPane = getMyScrollPane();
 

JXLayer<JScrollPane> layer = new JXLayer<JScrollPane>(myScrollPane, new MouseScrollableUI());

// add the layer to a frame or a panel, like any other component frame.add(layer);

The MouseScrollableDemo is available

See Also:
Serialized Form

Constructor Summary
MouseScrollableUI()
          Creates a new instance of MouseScrollableUI.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void eventDispatched(java.awt.AWTEvent e, JXLayer<? extends javax.swing.JScrollPane> l)
          Dispatches AWTEvents for JXLayer and all it subcomponents to this LayerUI.

To enable the AWTEvent of particular type, you should call JXLayer.setLayerEventMask(long) in LayerUI.installUI(javax.swing.JComponent) and set the layer event mask to 0 in LayerUI.uninstallUI(javax.swing.JComponent) after that

This method calls the appropriate process<eventType>Event method for the given class of event.

Preprocesses the AWTEvent to deactivate mouse scrolling when any key was pressed or focus left the JXLayer.

 void installUI(javax.swing.JComponent c)
          Configures the JXLayer this LayerUI is set to.
protected  boolean isMouseScrollingTrigger(java.awt.event.MouseEvent mouseEvent)
          Returns true if mouseEvent is a mouse auto-scrolling trigger.
protected  void processMouseEvent(java.awt.event.MouseEvent e, JXLayer<? extends javax.swing.JScrollPane> l)
          Processes MouseEvent occurring on the JXLayer or any of its subcomponents.

Activates the mouse auto-scrolling if e is a scrolling trigger.

protected  void processMouseMotionEvent(java.awt.event.MouseEvent e, JXLayer<? extends javax.swing.JScrollPane> l)
          Processes mouse motion events occurring on the JXLayer or any of its subcomponents.

Scrolls the JXLayer's view JScrollPane if mouse scrolling is activated

 void uninstallUI(javax.swing.JComponent c)
          
 
Methods inherited from class org.jdesktop.jxlayer.plaf.AbstractLayerUI
configureGraphics, getClip, getComposite, getLayerEventMask, getRenderingHints, getTransform, handlePropertyChangeEvent, isDirty, paint, paintLayer, processFocusEvent, processKeyEvent, processMouseWheelEvent, setDirty
 
Methods inherited from class org.jdesktop.jxlayer.plaf.LayerUI
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, getPreferredScrollableViewportSize, getPropertyChangeListeners, getPropertyChangeListeners, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, removePropertyChangeListener, removePropertyChangeListener, updateUI
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, createUI, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, getPreferredSize, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MouseScrollableUI

public MouseScrollableUI()
Creates a new instance of MouseScrollableUI.

Method Detail

installUI

public void installUI(javax.swing.JComponent c)
Description copied from class: LayerUI
Configures the JXLayer this LayerUI is set to. The default implementation registers the LayerUI as a property change listener for the passed JXLayer

Overrides:
installUI in class AbstractLayerUI<javax.swing.JScrollPane>
Parameters:
c - the JXLayer where this UI delegate is being installed

uninstallUI

public void uninstallUI(javax.swing.JComponent c)
Description copied from class: LayerUI

Overrides:
uninstallUI in class AbstractLayerUI<javax.swing.JScrollPane>

processMouseEvent

protected void processMouseEvent(java.awt.event.MouseEvent e,
                                 JXLayer<? extends javax.swing.JScrollPane> l)
Processes MouseEvent occurring on the JXLayer or any of its subcomponents.

Activates the mouse auto-scrolling if e is a scrolling trigger.

Overrides:
processMouseEvent in class AbstractLayerUI<javax.swing.JScrollPane>
Parameters:
e - the MouseEvent to be processed
l - the layer this LayerUI is set to
See Also:
isMouseScrollingTrigger(MouseEvent)

isMouseScrollingTrigger

protected boolean isMouseScrollingTrigger(java.awt.event.MouseEvent mouseEvent)
Returns true if mouseEvent is a mouse auto-scrolling trigger.

Parameters:
mouseEvent - the mouseEvent to be tested
Returns:
true if mouseEvent is a mouse auto-scrolling trigger, otherwise returns false

processMouseMotionEvent

protected void processMouseMotionEvent(java.awt.event.MouseEvent e,
                                       JXLayer<? extends javax.swing.JScrollPane> l)
Processes mouse motion events occurring on the JXLayer or any of its subcomponents.

Scrolls the JXLayer's view JScrollPane if mouse scrolling is activated

Overrides:
processMouseMotionEvent in class AbstractLayerUI<javax.swing.JScrollPane>
Parameters:
e - the MouseEvent to be processed
l - the layer this LayerUI is set to

eventDispatched

public void eventDispatched(java.awt.AWTEvent e,
                            JXLayer<? extends javax.swing.JScrollPane> l)
Dispatches AWTEvents for JXLayer and all it subcomponents to this LayerUI.

To enable the AWTEvent of particular type, you should call JXLayer.setLayerEventMask(long) in LayerUI.installUI(javax.swing.JComponent) and set the layer event mask to 0 in LayerUI.uninstallUI(javax.swing.JComponent) after that

This method calls the appropriate process<eventType>Event method for the given class of event.

Preprocesses the AWTEvent to deactivate mouse scrolling when any key was pressed or focus left the JXLayer.

Overrides:
eventDispatched in class AbstractLayerUI<javax.swing.JScrollPane>
Parameters:
e - the event to be dispatched
l - the layer this LayerUI is set to
See Also:
JXLayer.setLayerEventMask(long), JXLayer.getLayerEventMask()

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener