1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005-2006 Grigor Iliev <grigor@grigoriliev.com> |
* Copyright (C) 2005-2007 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 org.jvnet.lafwidget.animation.FadeConfigurationManager; |
35 |
|
import org.jvnet.lafwidget.animation.FadeKind; |
36 |
|
|
37 |
|
import org.jvnet.substance.SubstanceLookAndFeel; |
38 |
|
|
39 |
|
|
40 |
/** |
/** |
41 |
* |
* |
42 |
* @author Grigor Iliev |
* @author Grigor Iliev |
43 |
*/ |
*/ |
44 |
public class PixmapButton extends JButton { |
public class PixmapButton extends JButton { |
45 |
|
private Dimension size; |
46 |
|
|
47 |
/** Creates a new instance of PixmapButton */ |
/** Creates a new instance of PixmapButton */ |
48 |
PixmapButton(ImageIcon icon) { |
PixmapButton(ImageIcon icon) { |
49 |
this(icon, null); |
this(icon, null); |
51 |
|
|
52 |
/** Creates a new instance of PixmapButton */ |
/** Creates a new instance of PixmapButton */ |
53 |
PixmapButton(ImageIcon icon, ImageIcon rolloverIcon) { |
PixmapButton(ImageIcon icon, ImageIcon rolloverIcon) { |
54 |
setBorder(BorderFactory.createEmptyBorder()); |
initPixmapButton(icon, rolloverIcon); |
55 |
|
} |
56 |
|
|
57 |
|
/** Creates a new instance of PixmapButton */ |
58 |
|
PixmapButton(Action a, ImageIcon icon) { |
59 |
|
super(a); |
60 |
|
initPixmapButton(icon, null); |
61 |
|
} |
62 |
|
|
63 |
|
private void |
64 |
|
initPixmapButton(ImageIcon icon, ImageIcon rolloverIcon) { |
65 |
|
setText(""); |
66 |
setContentAreaFilled(false); |
setContentAreaFilled(false); |
67 |
setFocusPainted(false); |
setFocusPainted(false); |
68 |
|
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
69 |
setMargin(new Insets(0, 0, 0, 0)); |
setMargin(new Insets(0, 0, 0, 0)); |
70 |
|
putClientProperty(SubstanceLookAndFeel.BUTTON_PAINT_NEVER_PROPERTY, Boolean.TRUE); |
71 |
|
putClientProperty(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE); |
72 |
|
//putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE); |
73 |
|
FadeConfigurationManager.getInstance().disallowFades(FadeKind.ROLLOVER, this); |
74 |
|
|
75 |
setIcon(icon); |
setIcon(icon); |
76 |
|
|
81 |
setRolloverEnabled(false); |
setRolloverEnabled(false); |
82 |
} |
} |
83 |
|
|
84 |
setPreferredSize(getMinimumSize()); |
size = new Dimension(icon.getIconWidth(), icon.getIconHeight()); |
85 |
setMaximumSize(getMinimumSize()); |
setPreferredSize(size); |
86 |
|
setMaximumSize(size); |
87 |
|
|
88 |
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
89 |
} |
} |