gpt4 book ai didi

java - 从 JScrollPane 中的 Swing 滚动条中删除箭头

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:58:57 25 4
gpt4 key购买 nike

我想从 JScrollPane 的滚动条中删除滚动条箭头按钮。我该怎么做?

最佳答案

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
}

删除按钮为那时留出空间。我发现让按钮归零是最简单的方法。

关于java - 从 JScrollPane 中的 Swing 滚动条中删除箭头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1786886/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com