📄 doubleheadedscrollbarui.java
字号:
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import javax.swing.JComponent;
import javax.swing.SwingConstants;
import javax.swing.event.MouseInputAdapter;
import javax.swing.plaf.metal.MetalScrollBarUI;
import javax.swing.plaf.metal.MetalScrollButton;
/**
* DoubleHeadedScrollbarUI provides the look and feel (i.e., output and input)
* for a DoubleHeadedScrollbar, by adding two draggable buttons to the
* ends of the thumb.
*/
public class DoubleHeadedScrollbarUI extends MetalScrollBarUI {
/**
* Attach this look-and-feel delegate to its component.
* Typically creates and adds new subcomponents to c,
* attaches listeners, and intializes this delegate.
*
* @param c scrollbar (must be a DoubleHeadedScrollbar) that
* this delegate will be handling input and output
* for.
*/
public void installUI(JComponent c) {
super.installUI(c);
// here's how to create a left-pointing arrow button:
// new MetalScrollButton(SwingConstants.WEST, scrollBarWidth, true);
}
/**
* Called to set the bounding rectangle of the scroll thumb.
* We override it here because we need to position buttons
* on top of the thumb.
* <p>
* When the thumb is as big as the scrollbar, this method
* is called with (0,0,0,0).
*
* @param x left edge of thumb, relative to scrollbar's coordinate system
* @param y top edge of thumb, relative to scrollbar's coordinate system
* @param width width of thumb in pixels
* @param height height of thumb in pixels
*/
protected void setThumbBounds(int x, int y, int width, int height) {
super.setThumbBounds(x, y, width, height);
// your code here
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -