1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005, 2006 Grigor Kirilov Iliev |
* Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
23 |
package org.jsampler.view.fantasia; |
package org.jsampler.view.fantasia; |
24 |
|
|
25 |
import java.awt.Cursor; |
import java.awt.Cursor; |
26 |
|
import java.awt.Dimension; |
27 |
import java.awt.Insets; |
import java.awt.Insets; |
28 |
|
|
29 |
|
import javax.swing.Action; |
30 |
import javax.swing.BorderFactory; |
import javax.swing.BorderFactory; |
31 |
import javax.swing.ImageIcon; |
import javax.swing.ImageIcon; |
32 |
import javax.swing.JButton; |
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 |
* @author Grigor Iliev |
45 |
*/ |
*/ |
46 |
public class PixmapButton extends JButton { |
public class PixmapButton extends JButton { |
47 |
|
private Dimension size; |
48 |
|
|
49 |
/** Creates a new instance of PixmapButton */ |
/** Creates a new instance of PixmapButton */ |
50 |
PixmapButton(ImageIcon icon) { |
PixmapButton(ImageIcon icon) { |
51 |
this(icon, null); |
this(icon, null); |
53 |
|
|
54 |
/** Creates a new instance of PixmapButton */ |
/** Creates a new instance of PixmapButton */ |
55 |
PixmapButton(ImageIcon icon, ImageIcon rolloverIcon) { |
PixmapButton(ImageIcon icon, ImageIcon rolloverIcon) { |
56 |
setBorder(BorderFactory.createEmptyBorder()); |
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); |
setContentAreaFilled(false); |
69 |
setFocusPainted(false); |
setFocusPainted(false); |
70 |
|
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
71 |
setMargin(new Insets(0, 0, 0, 0)); |
setMargin(new Insets(0, 0, 0, 0)); |
72 |
|
|
73 |
setIcon(icon); |
setIcon(icon); |
74 |
|
|
75 |
if(rolloverIcon != null) { |
if(rolloverIcon != null) { |
79 |
setRolloverEnabled(false); |
setRolloverEnabled(false); |
80 |
} |
} |
81 |
|
|
82 |
setPreferredSize(getMinimumSize()); |
size = new Dimension(icon.getIconWidth(), icon.getIconHeight()); |
83 |
setMaximumSize(getMinimumSize()); |
setPreferredSize(size); |
84 |
|
setMaximumSize(size); |
85 |
|
|
86 |
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
87 |
} |
} |
88 |
|
|
89 |
|
public void |
90 |
|
updateUI() { setUI(new BasicButtonUI()); } |
91 |
} |
} |