|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.swing.plaf.ComponentUI
org.jdesktop.jxlayer.plaf.LayerUI<V>
org.jdesktop.jxlayer.plaf.AbstractLayerUI<javax.swing.JScrollPane>
org.jdesktop.jxlayer.plaf.ext.MouseScrollableUI
public class MouseScrollableUI
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.
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
| Constructor Summary | |
|---|---|
MouseScrollableUI()
Creates a new instance of MouseScrollableUI. |
|
MouseScrollableUI(boolean isAWTEventListenerEnabled)
Creates a new instance of MouseScrollableUI. |
|
| Method Summary | |
|---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
|
void |
eventDispatched(java.awt.AWTEvent e,
JXLayer<javax.swing.JScrollPane> l)
Dispatches all input and focus events from the JXLayer
and all it subcomponents to this LayerUI,
when LayerItem.isEnabled() returns true.
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 specified JXLayer appropriate for this AbstractLayerUI. |
protected boolean |
isAWTEventListenerEnabled()
Returns true if this AbstractLayerUI catches AWT events
with help of AWTEventListener,
in this case AbstractLayerUI.registerAWTEventListener(JXLayer, long)
will be called from installUI(JComponent)
with AbstractLayerUI.getLayerEventMask() as the second parameter
and AbstractLayerUI.unregisterAWTEventListener(JXLayer)
will be called from uninstallUI(JComponent)
If this method is overridden to return true
don't forget to override getAWTEventListenerEventMask()
The default implementation returns false |
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<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<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 |
setEnabled(boolean enabled)
Enables or disables this component, depending on the value of the parameter enabled.
Deactivates the mouse scrolling for disabled MouseScrollableUI |
void |
uninstallUI(javax.swing.JComponent c)
Reverses configuration which was done on the specified component during installUI(JComponent). |
| Methods inherited from class org.jdesktop.jxlayer.plaf.LayerUI |
|---|
getAccessibleChild, getAccessibleChildrenCount, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, isEventEnabled, update, updateUI |
| Methods inherited from class javax.swing.plaf.ComponentUI |
|---|
contains, createUI, getMaximumSize, getMinimumSize, getPreferredSize |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MouseScrollableUI()
MouseScrollableUI.
public MouseScrollableUI(boolean isAWTEventListenerEnabled)
MouseScrollableUI.
isAWTEventListenerEnabled - if true then the AWTEventListener
will be used to catch the AWT events| Method Detail |
|---|
public void installUI(javax.swing.JComponent c)
AbstractLayerUIJXLayer appropriate for this AbstractLayerUI.
This method is invoked when the LayerUI instance is being installed
as the UI delegate on the specified JXLayer.
Subclasses can install any listeners to the passed JXLayer,
configure its glassPane or do any other setting up.
The default implementation registers the passed JXLayer
as a LayerItemListener for this AbstractLayerUI.
Note: Subclasses can safely cast the passed component
to the JXLayer<V>
installUI in class AbstractLayerUI<javax.swing.JScrollPane>c - the JXLayer where this UI delegate is being installedAbstractLayerUI.uninstallUI(JComponent)public void uninstallUI(javax.swing.JComponent c)
AbstractLayerUIinstallUI(JComponent). This method is invoked when this
LayerUI instance is being removed as the UI delegate
for the specified JXLayer.
uninstallUI(JComponent) should undo the
configuration performed in installUI(JComponent), being careful to
leave the JXLayer instance in a clean state
(e.g. all previously set listeners must be removed in this method).
The default implementation removes the passed JXLayer
from the LayerItemListener's list of this AbstractLayerUI.
Note: Subclasses can safely cast the passed component
to the JXLayer<V>
uninstallUI in class AbstractLayerUI<javax.swing.JScrollPane>c - the JXLayer where this UI delegate is being installedAbstractLayerUI.installUI(JComponent)protected boolean isAWTEventListenerEnabled()
true if this AbstractLayerUI catches AWT events
with help of AWTEventListener,
in this case AbstractLayerUI.registerAWTEventListener(JXLayer, long)
will be called from installUI(JComponent)
with AbstractLayerUI.getLayerEventMask() as the second parameter
and AbstractLayerUI.unregisterAWTEventListener(JXLayer)
will be called from uninstallUI(JComponent)
If this method is overridden to return true
don't forget to override getAWTEventListenerEventMask()
The default implementation returns false
isAWTEventListenerEnabled in class AbstractLayerUI<javax.swing.JScrollPane>true if this AbstractLayerUI catches AWT events
with help of AWTEventListener(),
AbstractLayerUI.registerAWTEventListener(JXLayer, long)public void setEnabled(boolean enabled)
enabled. An enabled LayerUI paints
the JXLayers components they are set to and receives
their input and focuse events.
AbstractLayerUI is enabled initially by default.
Deactivates the mouse scrolling for disabled MouseScrollableUI
setEnabled in class AbstractLayerUI<javax.swing.JScrollPane>enabled - If true, this AbstractLayerUI is
enabled; otherwise this AbstractLayerUI is disabled
protected void processMouseEvent(java.awt.event.MouseEvent e,
JXLayer<javax.swing.JScrollPane> l)
MouseEvent occurring on the JXLayer
or any of its subcomponents.
Activates the mouse auto-scrolling if e is a scrolling trigger.
processMouseEvent in class AbstractLayerUI<javax.swing.JScrollPane>e - the MouseEvent to be processedl - the layer this LayerUI is set toisMouseScrollingTrigger(MouseEvent)protected boolean isMouseScrollingTrigger(java.awt.event.MouseEvent mouseEvent)
true if mouseEvent is a mouse auto-scrolling trigger.
mouseEvent - the mouseEvent to be tested
true if mouseEvent is a mouse auto-scrolling trigger,
otherwise returns false
protected void processMouseMotionEvent(java.awt.event.MouseEvent e,
JXLayer<javax.swing.JScrollPane> l)
JXLayer
or any of its subcomponents.
Scrolls the JXLayer's view JScrollPane
if mouse scrolling is activated
processMouseMotionEvent in class AbstractLayerUI<javax.swing.JScrollPane>e - the MouseEvent to be processedl - the layer this LayerUI is set to
public void eventDispatched(java.awt.AWTEvent e,
JXLayer<javax.swing.JScrollPane> l)
JXLayer
and all it subcomponents to this LayerUI,
when LayerItem.isEnabled() returns true.
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.
eventDispatched in class AbstractLayerUI<javax.swing.JScrollPane>e - the event to be dispatchedl - the layer this LayerUI is set topublic void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed in interface java.awt.event.ActionListener
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||