本文介绍了从JScrollPane中的Swing Scrollbar中删除箭头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从JScrollPane中的滚动条中删除滚动条箭头按钮。我该怎么做?
I would like to remove the scrollbar arrow buttons from a scrollbar in a JScrollPane. How would I do this?
推荐答案
class NoArrowScrollBarUI extends BasicScrollBarUI {
protected JButton createZeroButton() {
JButton button = new JButton("zero button");
Dimension zeroDim = new Dimension(0,0);
button.setPreferredSize(zeroDim);
button.setMinimumSize(zeroDim);
button.setMaximumSize(zeroDim);
return button;
}
@Override
protected JButton createDecreaseButton(int orientation) {
return createZeroButton();
}
@Override
protected JButton createIncreaseButton(int orientation) {
return createZeroButton();
}
@Override
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
//own painting if needed
}
@Override
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
//own painting if needed
}
}
删除按钮可以留出空间。我发现make按钮为零是最简单的方法。
Removing buttons let space for then. I found make buttons zero as the simplest way.
这篇关于从JScrollPane中的Swing Scrollbar中删除箭头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!