java按钮点击处于当前焦点的时候,能否边框线不在文字边沿,而是在按钮边沿呢?就像windows的按钮那样,焦点时的边框线都是在按钮边沿的。
解决方案 »
- 我在我的frame中放置了两个Splitpane,三个panel,每个panel中放了一个jtable,但是拖动不了,不知是为什么
- 三种方法可以取返回long类型的疑问
- 新鲜出炉的用JAVA写的小游戏..点点世界V1.0发布!
- JAVA新手的两个问题(强制类型转换、接口/抽象类)
- 在public class Second{}如何引用同一个包中的public class first{}中的变量和控件??
- list里面取随机几个对象问题
- 使用Java的AWT包来开发一个能够进行加、减、乘、除四则运算的计算器。大家如果有做好的,能不能发一份到我邮箱啊
- 操作excel表格,poi与jxl哪个更好
- 如何得到快捷方式指定的文件
- java高并发业务的性能问题
- 麻烦大家帮我看看这个程序,感谢了!
- java 特别基础的问题(急)
import javax.swing.UIManager;
import javax.swing.plaf.metal.MetalButtonUI;
import java.awt.Graphics;
import java.awt.Rectangle;public class MyButtonUI extends MetalButtonUI{
int rectGapX;
int rectGapY;
int rectGapW;
int rectGapH;
public MyButtonUI() {
rectGapX = UIManager.getInt("ButtonUI.dashedRectGapX");
rectGapY = UIManager.getInt("ButtonUI.dashedRectGapY");
rectGapW = UIManager.getInt("ButtonUI.dashedRectGapWidth");
rectGapH = UIManager.getInt("ButtonUI.dashedRectGapHeight");
} protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect,
Rectangle textRect, Rectangle iconRect) {
textRect = new Rectangle(rectGapX+3, rectGapY+3, b.getWidth()-rectGapW-6,
b.getHeight()-rectGapH-6);
super.paintFocus(g, b, viewRect, textRect, iconRect);
}
}使用如下JButton button = new JButton("test Button");
MyButtonUI bui = new MyButtonUI();
button.setUI(bui);
Insets inset = new Insets(1,1,1,1); //这个数值就是那个边框线离四个边框的距离
button.setMargin(inset); OK了