BasicArrowButton是一个类,是Java SE的一部分。 BasicArrowButton在指定方向上显示单个箭头。我想覆盖该类,保留现有方法,但让基本箭头按钮显示双箭头而不是单箭头。例如,请参见以下URL www.tiresias.org/images/ff.jpg。我要做的就是改变这个图标的绘制方式。
谢谢,
答案 0 :(得分:8)
子类 BasicArrowButton 并覆盖 paintTriangle 。您可以尝试两次调用 BasicArrowButton 的 paintTriangle 方法来获取三角形。例如:
public static class Bidriectional extends BasicArrowButton {
private static final long serialVersionUID = 1L;
public Bidriectional() {
// This does not matter, we'll override it anyways.
super(SwingConstants.NORTH);
}
@Override
public void paintTriangle(Graphics g, int x, int y, int size,
int direction, boolean isEnabled) {
super.paintTriangle(g, x - (size / 2), y, size, SwingConstants.EAST, isEnabled);
super.paintTriangle(g, x + (size / 2), y, size, SwingConstants.EAST, isEnabled);
}
}
应该给你一个看起来像这样的按钮:
screenshot http://www.amnet.net.au/~kgoh/images/double_arrow.jpg
答案 1 :(得分:1)