1 package org.splat.launcher;
3 import java.awt.Button;
5 import java.awt.Cursor;
6 import java.awt.Graphics;
10 public class ToolButton extends Button {
13 private int orx; // X of the icon top left corner
14 private int ory; // Y of the icon top left corner
16 private String target;
18 private static final long serialVersionUID = 5723786125423445749L;
20 // ==============================================================================================================================
22 // ==============================================================================================================================
24 public ToolButton (int size, Image icon, String link) {
25 // -----------------------------------------------------
26 this(size, icon, link, null);
28 public ToolButton (int size, Image icon, String link, String target) {
29 // --------------------------------------------------------------------
30 orx = 24; // icon.getWidth(this); seems returning 0 before being painted
31 ory = 24; // icon.getHeight(this); seems returning 0 before being painted
32 if (orx < size) orx = (size - orx) / 2;
34 if (ory < size) ory = (size - ory) / 2;
40 this.setSize(size, size);
41 this.setCursor(new Cursor(Cursor.HAND_CURSOR));
44 // ==============================================================================================================================
45 // Overridden functions
46 // ==============================================================================================================================
48 public void paint(Graphics screen) {
49 // ----------------------------------
50 screen.drawImage(icon, orx, ory, new Color(205, 229, 255), this);
53 // ==============================================================================================================================
55 // ==============================================================================================================================
57 public String getTool () {
58 // ------------------------
62 public String getTarget () {
63 // --------------------------