1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
6 |
* This file is part of JSampler. |
7 |
* |
8 |
* JSampler is free software; you can redistribute it and/or modify |
9 |
* it under the terms of the GNU General Public License version 2 |
10 |
* as published by the Free Software Foundation. |
11 |
* |
12 |
* JSampler is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with JSampler; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
20 |
* MA 02111-1307 USA |
21 |
*/ |
22 |
|
23 |
package org.jsampler.view.fantasia; |
24 |
|
25 |
import java.awt.Cursor; |
26 |
import java.awt.Dimension; |
27 |
import java.awt.Insets; |
28 |
|
29 |
import javax.swing.Action; |
30 |
import javax.swing.BorderFactory; |
31 |
import javax.swing.ImageIcon; |
32 |
import javax.swing.JButton; |
33 |
|
34 |
import javax.swing.plaf.basic.BasicButtonUI; |
35 |
|
36 |
import org.jvnet.lafwidget.animation.FadeConfigurationManager; |
37 |
import org.jvnet.lafwidget.animation.FadeKind; |
38 |
|
39 |
import org.jvnet.substance.SubstanceLookAndFeel; |
40 |
|
41 |
|
42 |
/** |
43 |
* |
44 |
* @author Grigor Iliev |
45 |
*/ |
46 |
public class PixmapButton extends JButton { |
47 |
private Dimension size; |
48 |
|
49 |
/** Creates a new instance of PixmapButton */ |
50 |
PixmapButton(ImageIcon icon) { |
51 |
this(icon, null); |
52 |
} |
53 |
|
54 |
/** Creates a new instance of PixmapButton */ |
55 |
PixmapButton(ImageIcon icon, ImageIcon rolloverIcon) { |
56 |
initPixmapButton(icon, rolloverIcon); |
57 |
} |
58 |
|
59 |
/** Creates a new instance of PixmapButton */ |
60 |
PixmapButton(Action a, ImageIcon icon) { |
61 |
super(a); |
62 |
initPixmapButton(icon, null); |
63 |
} |
64 |
|
65 |
private void |
66 |
initPixmapButton(ImageIcon icon, ImageIcon rolloverIcon) { |
67 |
setText(""); |
68 |
setContentAreaFilled(false); |
69 |
setFocusPainted(false); |
70 |
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
71 |
setMargin(new Insets(0, 0, 0, 0)); |
72 |
|
73 |
setIcon(icon); |
74 |
|
75 |
if(rolloverIcon != null) { |
76 |
setRolloverIcon(rolloverIcon); |
77 |
setRolloverEnabled(true); |
78 |
} else { |
79 |
setRolloverEnabled(false); |
80 |
} |
81 |
|
82 |
size = new Dimension(icon.getIconWidth(), icon.getIconHeight()); |
83 |
setPreferredSize(size); |
84 |
setMaximumSize(size); |
85 |
|
86 |
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
87 |
} |
88 |
|
89 |
public void |
90 |
updateUI() { setUI(new BasicButtonUI()); } |
91 |
} |