File: ArrowButton.java

package info (click to toggle)
libswidgets-java 0.1.4-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, squeeze
  • size: 356 kB
  • ctags: 667
  • sloc: java: 3,436; xml: 64; makefile: 11
file content (50 lines) | stat: -rw-r--r-- 1,522 bytes parent folder | download
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());
    }
}