自定义外观的Button怎么制作? 想设计自定义的Button,像VB里可以接受点击事件的Label控件一样的Button应该怎么做? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 package app.inspec_client.gui;import java.awt.Font;import javax.swing.Action;import javax.swing.Icon;import javax.swing.JButton;import javax.swing.SwingConstants;public class MyButton extends JButton { /** * */ private static final long serialVersionUID = 1L; public MyButton(Action a) { super(a); setProperties(); } public MyButton(Icon icon) { super(icon); setProperties(); } public MyButton(String text, Icon icon) { super(text, icon); setProperties(); } public MyButton(String text) { super(text); setProperties(); } private void setProperties() { this.setToolTipText("执行" + this.getText() + "操作"); setOpaque(false); this.setFont(new Font("宋体", 0, 12)); this.setIconTextGap(1); this.setBorderPainted(false); this.setFocusable(false); // setBorder( BorderFactory.createRaisedBevelBorder()); this.setVerticalTextPosition(SwingConstants.BOTTOM); setHorizontalTextPosition(SwingConstants.CENTER); }}产生按钮MyButton bt_check=new MyButton(new AbstractAction("审核", icon_add){}); 似乎这个方法还没有摆脱JButton的外观。设置Icon后,Icon旁还是会出现JButton原来的按钮外表,我需要的是完全不同的Button,不知还有什么高招没 .......好似是JSP的东东,不是我要的 你可以用Netbeans IDE 里面可以完成你的BUTTON属性了! 1、写一个继承自JButton的子类,复写paintComponent方法,自己画出一个满足要求的按钮来2、使用装饰器模式,对JButton外观进行一下改变 我建议你使用NetBeans6.0中文版开发! 在那里可以很方便的制作个性化的桌面系统!NetBeans6.0中文版下载地址是:http://bits.netbeans.org/netbeans/6.0.1/ml/nightly/latest/ 要彻底改变只能自己paintComponent Java求解 通过递归方法调用将文件路径储存到字符数组 问个集合的问题 j2se+spring 出现的问题 有人准备考研了,大家给个建议 多态问题帮我看看看谢谢 ,有2段输出结果不理解 PopupMenu事件 java调用sql server问题 一个简单问题!送分来了! 如何把double类型值转换成字节 static final变量存储内存哪个区? 不解: 用数组初始化jTable时,为什么在jTable输出之后,数组的改变还能起作用....
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.SwingConstants;public class MyButton extends JButton { /**
*
*/
private static final long serialVersionUID = 1L; public MyButton(Action a) {
super(a);
setProperties();
} public MyButton(Icon icon) {
super(icon);
setProperties(); } public MyButton(String text, Icon icon) {
super(text, icon);
setProperties();
} public MyButton(String text) {
super(text);
setProperties();
} private void setProperties() {
this.setToolTipText("执行" + this.getText() + "操作");
setOpaque(false);
this.setFont(new Font("宋体", 0, 12));
this.setIconTextGap(1);
this.setBorderPainted(false);
this.setFocusable(false); // setBorder( BorderFactory.createRaisedBevelBorder());
this.setVerticalTextPosition(SwingConstants.BOTTOM);
setHorizontalTextPosition(SwingConstants.CENTER); }
}产生按钮
MyButton bt_check=new MyButton(new AbstractAction("审核", icon_add){});
2、使用装饰器模式,对JButton外观进行一下改变
NetBeans6.0中文版下载地址是:http://bits.netbeans.org/netbeans/6.0.1/ml/nightly/latest/