/[svn]/jsampler/trunk/src/org/jsampler/view/fantasia/PixmapButton.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/view/fantasia/PixmapButton.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1285 - (show annotations) (download)
Fri Aug 10 19:55:03 2007 UTC (16 years, 8 months ago) by iliev
File size: 2634 byte(s)
* Updated to version 0.6a. The Fantasia distribution is now
  capable of controlling all features available in LinuxSampler

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2007 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 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
43 */
44 public class PixmapButton extends JButton {
45 private Dimension size;
46
47 /** Creates a new instance of PixmapButton */
48 PixmapButton(ImageIcon icon) {
49 this(icon, null);
50 }
51
52 /** Creates a new instance of PixmapButton */
53 PixmapButton(ImageIcon icon, ImageIcon rolloverIcon) {
54 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);
67 setFocusPainted(false);
68 setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
69 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);
76
77 if(rolloverIcon != null) {
78 setRolloverIcon(rolloverIcon);
79 setRolloverEnabled(true);
80 } else {
81 setRolloverEnabled(false);
82 }
83
84 size = new Dimension(icon.getIconWidth(), icon.getIconHeight());
85 setPreferredSize(size);
86 setMaximumSize(size);
87
88 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
89 }
90 }

  ViewVC Help
Powered by ViewVC