如何改变JComboBox的倒三角图标 现在在做一个项目,看JComboBox的倒三角图标很难看,能把它换一个图片么。如何实现呢.... 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 改变整个Swing的风格或许可以实现 难看?呵呵,许是我看多了,没感觉了吧。如果要改这个button,需要你更改BasicComboboxUI里面的东西。源码声明如下: // The arrow button that invokes the popup. protected JButton arrowButton;而实现的时候protected void installComponents() { arrowButton = createArrowButton(); comboBox.add( arrowButton ); …… ……你可以看一下createArrowButton的实现:protected JButton createArrowButton() { JButton button = new BasicArrowButton(BasicArrowButton.SOUTH, UIManager.getColor("ComboBox.buttonBackground"), UIManager.getColor("ComboBox.buttonShadow"), UIManager.getColor("ComboBox.buttonDarkShadow"), UIManager.getColor("ComboBox.buttonHighlight")); button.setName("ComboBox.arrowButton"); return button; }如果你有兴趣可以参考BasicArrowButton的类。但是如果你只是要改箭头方向的话,就不必了。默认的是BasicArrowButton.SOUTH。可以有EAST,WEST,NORTH,都是SwingConstants中的常量。如果要换个按钮,那你自己去定义,设置图标。说到这了已经,那该怎么做,你应该很清楚了吧? 1.有两个字符串,a="1983年03月20日",b="2008年08月08日",问两个字符串所 指代的日期相差多少天 有个问题没明白请大家帮忙 一道垃圾回收的题,高手请进! 请教关于Graphics类中drawImage方法的用法 关于LinkedList的问题,求逆置算法! Dialog弹出位置的问题? 初学java,如何编译? 什么情况下两个对象可以用“==”或者“!=”来比较啊? 在JAVA中用JDBC如何连接SQLSERVER数据库,如何不通过ODBC连接,用ADO或其他方式。 吐血求教! java WEB求助 反序列化报错java.io.ioexception
如果要改这个button,需要你更改BasicComboboxUI里面的东西。
源码声明如下:
// The arrow button that invokes the popup.
protected JButton arrowButton;而实现的时候
protected void installComponents() {
arrowButton = createArrowButton();
comboBox.add( arrowButton );
……
……你可以看一下createArrowButton的实现:protected JButton createArrowButton() {
JButton button = new BasicArrowButton(BasicArrowButton.SOUTH,
UIManager.getColor("ComboBox.buttonBackground"),
UIManager.getColor("ComboBox.buttonShadow"),
UIManager.getColor("ComboBox.buttonDarkShadow"),
UIManager.getColor("ComboBox.buttonHighlight"));
button.setName("ComboBox.arrowButton");
return button;
}如果你有兴趣可以参考BasicArrowButton的类。但是如果你只是要改箭头方向的话,就不必了。默认的是
BasicArrowButton.SOUTH。可以有EAST,WEST,NORTH,都是SwingConstants中的常量。
如果要换个按钮,那你自己去定义,设置图标。
说到这了已经,那该怎么做,你应该很清楚了吧?