1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
/*
* ArrowButton.java
*/
package org.tigris.swidgets;
import javax.swing.border.Border;
import java.awt.*;
/**
* A simple arrow button that can be created to point to
* a compass point.
*
* @author Bob Tarling
*/
public class ArrowButton extends javax.swing.JButton {
private static final long serialVersionUID = -8897576333357419116L;
/** Construct an ArrowButton pointing in the given direction
*
* @param direction the direction the arrow will point, this being
* one of the constants NORTH, SOUTH, EAST, WEST
*/
public ArrowButton(int direction, Border border) {
this(direction);
setBorder(border);
}
/** Construct an ArrowButton pointing in the given direction
*
* @param direction the direction the arrow will point, this being
* one of the constants NORTH, SOUTH, EAST, WEST
*/
public ArrowButton(int direction) {
super();
ArrowIcon arrowIcon = new ArrowIcon(direction);
setIcon(arrowIcon);
super.setFocusPainted(false);
setPreferredSize(new Dimension(arrowIcon.getIconWidth(),
arrowIcon.getIconHeight()));
setMinimumSize(new Dimension(arrowIcon.getIconWidth(),
arrowIcon.getIconHeight()));
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
public Dimension getPreferredSize() {
return new Dimension(getIcon().getIconWidth(),
getIcon().getIconHeight());
}
}
|