|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
package com.fr.design.gui.iscrollbar; |
|
|
|
|
|
|
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
import java.awt.Color; |
|
|
|
|
import java.awt.Component; |
|
|
|
|
import java.awt.Container; |
|
|
|
@ -20,7 +22,6 @@ import java.awt.event.MouseEvent;
|
|
|
|
|
import java.awt.event.MouseMotionListener; |
|
|
|
|
import java.beans.PropertyChangeEvent; |
|
|
|
|
import java.beans.PropertyChangeListener; |
|
|
|
|
|
|
|
|
|
import javax.swing.BoundedRangeModel; |
|
|
|
|
import javax.swing.InputMap; |
|
|
|
|
import javax.swing.JComponent; |
|
|
|
@ -38,8 +39,6 @@ import javax.swing.event.ChangeListener;
|
|
|
|
|
import javax.swing.plaf.ComponentUI; |
|
|
|
|
import javax.swing.plaf.ScrollBarUI; |
|
|
|
|
import javax.swing.plaf.UIResource; |
|
|
|
|
|
|
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
|
import sun.swing.DefaultLookup; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -148,6 +147,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
|
|
|
|
|
* |
|
|
|
|
* @param c |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void installUI(JComponent c) { |
|
|
|
|
scrollbar = (JScrollBar) c; |
|
|
|
|
thumbRect = new Rectangle(0, 0, 0, 0); |
|
|
|
@ -163,6 +163,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
|
|
|
|
|
* |
|
|
|
|
* @param c |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void uninstallUI(JComponent c) { |
|
|
|
|
scrollbar = (JScrollBar) c; |
|
|
|
|
uninstallListeners(); |
|
|
|
@ -357,6 +358,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
|
|
|
|
|
/** |
|
|
|
|
* 只画Thumb |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void paint(Graphics g, JComponent c) { |
|
|
|
|
Rectangle thumbBounds = getThumbBounds(); |
|
|
|
|
if (thumbBounds.intersects(g.getClipBounds())) { |
|
|
|
@ -380,6 +382,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
|
|
|
|
|
* @see #getMaximumSize |
|
|
|
|
* @see #getMinimumSize |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public Dimension getPreferredSize(JComponent c) { |
|
|
|
|
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 #getPreferredSize |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public Dimension getMaximumSize(JComponent c) { |
|
|
|
|
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; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
|
isPressing = false; |
|
|
|
|
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 |
|
|
|
|
* upper half of the track. |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
|
boolean isMiddle = !isSupportsAbsolutePositioning() && SwingUtilities.isMiddleMouseButton(e); |
|
|
|
|
if (SwingUtilities.isRightMouseButton(e) || isMiddle) { |
|
|
|
@ -1313,7 +1319,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
|
|
|
|
|
public void propertyChange(PropertyChangeEvent e) { |
|
|
|
|
String propertyName = e.getPropertyName(); |
|
|
|
|
|
|
|
|
|
if ("model" == propertyName) { |
|
|
|
|
if (StringUtils.equals("model", propertyName)) { |
|
|
|
|
BoundedRangeModel oldModel = (BoundedRangeModel) e.getOldValue(); |
|
|
|
|
BoundedRangeModel newModel = (BoundedRangeModel) e.getNewValue(); |
|
|
|
|
oldModel.removeChangeListener(modelListener); |
|
|
|
|