|
|
@ -1,5 +1,7 @@ |
|
|
|
package com.fr.design.gui.iscrollbar; |
|
|
|
package com.fr.design.gui.iscrollbar; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Component; |
|
|
|
import java.awt.Component; |
|
|
|
import java.awt.Container; |
|
|
|
import java.awt.Container; |
|
|
@ -20,7 +22,6 @@ import java.awt.event.MouseEvent; |
|
|
|
import java.awt.event.MouseMotionListener; |
|
|
|
import java.awt.event.MouseMotionListener; |
|
|
|
import java.beans.PropertyChangeEvent; |
|
|
|
import java.beans.PropertyChangeEvent; |
|
|
|
import java.beans.PropertyChangeListener; |
|
|
|
import java.beans.PropertyChangeListener; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.BoundedRangeModel; |
|
|
|
import javax.swing.BoundedRangeModel; |
|
|
|
import javax.swing.InputMap; |
|
|
|
import javax.swing.InputMap; |
|
|
|
import javax.swing.JComponent; |
|
|
|
import javax.swing.JComponent; |
|
|
@ -38,8 +39,6 @@ import javax.swing.event.ChangeListener; |
|
|
|
import javax.swing.plaf.ComponentUI; |
|
|
|
import javax.swing.plaf.ComponentUI; |
|
|
|
import javax.swing.plaf.ScrollBarUI; |
|
|
|
import javax.swing.plaf.ScrollBarUI; |
|
|
|
import javax.swing.plaf.UIResource; |
|
|
|
import javax.swing.plaf.UIResource; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
|
|
|
|
import sun.swing.DefaultLookup; |
|
|
|
import sun.swing.DefaultLookup; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -148,6 +147,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo |
|
|
|
* |
|
|
|
* |
|
|
|
* @param c |
|
|
|
* @param c |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
public void installUI(JComponent c) { |
|
|
|
public void installUI(JComponent c) { |
|
|
|
scrollbar = (JScrollBar) c; |
|
|
|
scrollbar = (JScrollBar) c; |
|
|
|
thumbRect = new Rectangle(0, 0, 0, 0); |
|
|
|
thumbRect = new Rectangle(0, 0, 0, 0); |
|
|
@ -163,6 +163,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo |
|
|
|
* |
|
|
|
* |
|
|
|
* @param c |
|
|
|
* @param c |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
public void uninstallUI(JComponent c) { |
|
|
|
public void uninstallUI(JComponent c) { |
|
|
|
scrollbar = (JScrollBar) c; |
|
|
|
scrollbar = (JScrollBar) c; |
|
|
|
uninstallListeners(); |
|
|
|
uninstallListeners(); |
|
|
@ -357,6 +358,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 只画Thumb |
|
|
|
* 只画Thumb |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
public void paint(Graphics g, JComponent c) { |
|
|
|
public void paint(Graphics g, JComponent c) { |
|
|
|
Rectangle thumbBounds = getThumbBounds(); |
|
|
|
Rectangle thumbBounds = getThumbBounds(); |
|
|
|
if (thumbBounds.intersects(g.getClipBounds())) { |
|
|
|
if (thumbBounds.intersects(g.getClipBounds())) { |
|
|
@ -380,6 +382,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo |
|
|
|
* @see #getMaximumSize |
|
|
|
* @see #getMaximumSize |
|
|
|
* @see #getMinimumSize |
|
|
|
* @see #getMinimumSize |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
public Dimension getPreferredSize(JComponent c) { |
|
|
|
public Dimension getPreferredSize(JComponent c) { |
|
|
|
return (scrollbar.getOrientation() == JScrollBar.VERTICAL) ? new Dimension(scrollBarWidth, 48) : new Dimension(48, scrollBarWidth); |
|
|
|
return (scrollbar.getOrientation() == JScrollBar.VERTICAL) ? new Dimension(scrollBarWidth, 48) : new Dimension(48, scrollBarWidth); |
|
|
|
} |
|
|
|
} |
|
|
@ -390,6 +393,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo |
|
|
|
* @see #getMinimumSize |
|
|
|
* @see #getMinimumSize |
|
|
|
* @see #getPreferredSize |
|
|
|
* @see #getPreferredSize |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
public Dimension getMaximumSize(JComponent c) { |
|
|
|
public Dimension getMaximumSize(JComponent c) { |
|
|
|
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); |
|
|
|
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); |
|
|
|
} |
|
|
|
} |
|
|
@ -937,6 +941,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo |
|
|
|
private transient int direction = +1; |
|
|
|
private transient int direction = +1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
isPressing = false; |
|
|
|
isPressing = false; |
|
|
|
if (isDragging) { |
|
|
|
if (isDragging) { |
|
|
@ -968,6 +973,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo |
|
|
|
* one page. If there is no thumb then page up if the mouse is in the |
|
|
|
* one page. If there is no thumb then page up if the mouse is in the |
|
|
|
* upper half of the track. |
|
|
|
* upper half of the track. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
boolean isMiddle = !isSupportsAbsolutePositioning() && SwingUtilities.isMiddleMouseButton(e); |
|
|
|
boolean isMiddle = !isSupportsAbsolutePositioning() && SwingUtilities.isMiddleMouseButton(e); |
|
|
|
if (SwingUtilities.isRightMouseButton(e) || isMiddle) { |
|
|
|
if (SwingUtilities.isRightMouseButton(e) || isMiddle) { |
|
|
@ -1313,7 +1319,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo |
|
|
|
public void propertyChange(PropertyChangeEvent e) { |
|
|
|
public void propertyChange(PropertyChangeEvent e) { |
|
|
|
String propertyName = e.getPropertyName(); |
|
|
|
String propertyName = e.getPropertyName(); |
|
|
|
|
|
|
|
|
|
|
|
if ("model" == propertyName) { |
|
|
|
if (StringUtils.equals("model", propertyName)) { |
|
|
|
BoundedRangeModel oldModel = (BoundedRangeModel) e.getOldValue(); |
|
|
|
BoundedRangeModel oldModel = (BoundedRangeModel) e.getOldValue(); |
|
|
|
BoundedRangeModel newModel = (BoundedRangeModel) e.getNewValue(); |
|
|
|
BoundedRangeModel newModel = (BoundedRangeModel) e.getNewValue(); |
|
|
|
oldModel.removeChangeListener(modelListener); |
|
|
|
oldModel.removeChangeListener(modelListener); |
|
|
|