jscrollpane滚动条外观 怎么设置jscrollpane的滚动条外观啊,包括滚动条所在的滚动区域 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 自定义一个UI类CustomScrollBarUI,让它继承自javax.swing.plaf.basic.BasicScrollBarUI,跟据需要重写protected void configureScrollBarColors()protectedJButton createDecreaseButton(int orientation)protected JButton createIncreaseButton(int orientation)等方法,然后在ScrollPane 中设置新的UIyourScrollPane.getVerticalScrollBar().setUI(new CustomScrollBarUI());就可以了。 import java.awt.Color;import javax.swing.JButton;import javax.swing.LookAndFeel;import javax.swing.plaf.basic.BasicArrowButton;import javax.swing.plaf.basic.BasicScrollBarUI;public class CustomScrollBarUI extends BasicScrollBarUI { protected void configureScrollBarColors() { LookAndFeel.installColors(scrollbar, "ScrollBar.background", "ScrollBar.foreground"); thumbHighlightColor = Color.red; // 在这里改成你想要的颜色 thumbLightShadowColor = Color.yellow; // 在这里改成你想要的颜色 thumbDarkShadowColor = Color.blue; // 在这里改成你想要的颜色 thumbColor = Color.green; // 在这里改成你想要的颜色 trackColor = Color.gray; // 在这里改成你想要的颜色 trackHighlightColor = Color.black; // 在这里改成你想要的颜色 } protected JButton createDecreaseButton(int orientation) { return createIncreaseButton(orientation); } protected JButton createIncreaseButton(int orientation) { return new BasicArrowButton(orientation, thumbColor, thumbLightShadowColor, thumbDarkShadowColor, thumbHighlightColor); }}用的时候:yourJScrollPane.getVerticalScrollBar().setUI(new CustomScrollBarUI());就行了 可以的,重写protected JButton createDecreaseButton(int orientation),protected JButton createIncreaseButton(int orientation)返回一个包含图片的JButton,详见JButton类… 求大神!!!RSES如何使用??? java 随机数 打印预览 请求 垃圾邮件检测技术方法。。 如何来检测用户有一段时间没有动键盘鼠标了? java实现动态加载时遇到的问题(有代码和编译错误提示) 关于JTree节点的问题 JAVA数据结构!进来看下,肯定值得思考!! java -Djava.security.policy求助 询网络发布的工具 在DOS窗口下输入javac -help命令帮组信息出现乱码(有图) new Random()和new Random(System.currentTimeMillis())两个构造方法到底是否等同?
javax.swing.plaf.basic.BasicScrollBarUI,
跟据需要重写
protected void configureScrollBarColors()protected
JButton createDecreaseButton(int orientation)
protected JButton createIncreaseButton(int orientation)
等方法,然后在ScrollPane 中设置新的UI
yourScrollPane.getVerticalScrollBar().setUI(new CustomScrollBarUI());
就可以了。
import java.awt.Color;import javax.swing.JButton;
import javax.swing.LookAndFeel;
import javax.swing.plaf.basic.BasicArrowButton;
import javax.swing.plaf.basic.BasicScrollBarUI;public class CustomScrollBarUI extends BasicScrollBarUI {
protected void configureScrollBarColors() {
LookAndFeel.installColors(scrollbar, "ScrollBar.background",
"ScrollBar.foreground");
thumbHighlightColor = Color.red; // 在这里改成你想要的颜色
thumbLightShadowColor = Color.yellow; // 在这里改成你想要的颜色
thumbDarkShadowColor = Color.blue; // 在这里改成你想要的颜色
thumbColor = Color.green; // 在这里改成你想要的颜色
trackColor = Color.gray; // 在这里改成你想要的颜色
trackHighlightColor = Color.black; // 在这里改成你想要的颜色
}
protected JButton createDecreaseButton(int orientation) {
return createIncreaseButton(orientation);
}
protected JButton createIncreaseButton(int orientation) {
return new BasicArrowButton(orientation, thumbColor,
thumbLightShadowColor, thumbDarkShadowColor,
thumbHighlightColor);
}
}
用的时候:yourJScrollPane.getVerticalScrollBar().setUI(new CustomScrollBarUI());就行了
protected JButton createIncreaseButton(int orientation)
返回一个包含图片的JButton,详见JButton类…