2
* Copyright 2005-2010 Kirill Grouchnikov, based on work by
3
* Sun Microsystems, Inc. All rights reserved.
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
package org.pushingpixels.substance.swingx;
21
import java.awt.BorderLayout;
22
import java.awt.event.MouseAdapter;
23
import java.awt.event.MouseEvent;
26
import javax.swing.plaf.ComponentUI;
28
import org.jdesktop.swingx.JXHeader;
29
import org.jdesktop.swingx.JXTipOfTheDay;
30
import org.jdesktop.swingx.plaf.UIManagerExt;
31
import org.jdesktop.swingx.plaf.basic.BasicTipOfTheDayUI;
32
import org.pushingpixels.lafwidget.animation.AnimationConfigurationManager;
33
import org.pushingpixels.lafwidget.animation.AnimationFacet;
34
import org.pushingpixels.substance.api.DecorationAreaType;
35
import org.pushingpixels.substance.api.SubstanceLookAndFeel;
36
import org.pushingpixels.substance.internal.animation.IconGlowTracker;
37
import org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities;
38
import org.pushingpixels.substance.internal.utils.icon.GlowingIcon;
41
* Substance-consistent UI delegate for {@link JXTipOfTheDay}.
43
* @author Kirill Grouchnikov
45
public class SubstanceTipOfTheDayUI extends BasicTipOfTheDayUI {
47
AnimationConfigurationManager.getInstance().allowAnimations(AnimationFacet.ICON_GLOW,
51
protected IconGlowTracker iconGlowTracker;
53
public static ComponentUI createUI(JComponent comp) {
54
SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp);
55
return new SubstanceTipOfTheDayUI((JXTipOfTheDay) comp);
59
* Creates a new UI delegate.
64
public SubstanceTipOfTheDayUI(JXTipOfTheDay tip) {
72
* org.jdesktop.swingx.plaf.basic.BasicTipOfTheDayUI#installComponents()
75
protected void installComponents() {
76
tipPane.setLayout(new BorderLayout());
79
JPanel mainPane = new JPanel(new BorderLayout());
80
JXHeader didYouKnow = new JXHeader();
81
didYouKnow.setTitle(UIManagerExt.getString(
82
"TipOfTheDay.didYouKnowText", tipPane.getLocale()));
83
SubstanceLookAndFeel.setDecorationType(didYouKnow,
84
DecorationAreaType.GENERAL);
86
Icon infoIcon = SubstanceLookAndFeel.isToUseConstantThemesOnDialogs() ? SubstanceCoreUtilities
87
.getIcon("resource/22/dialog-information.png")
88
: SubstanceCoreUtilities.getThemedIcon(this.tipPane,
89
SubstanceCoreUtilities
90
.getIcon("resource/22/dialog-information.png"));
92
this.iconGlowTracker = new IconGlowTracker(didYouKnow);
93
didYouKnow.setIcon(new GlowingIcon(infoIcon, this.iconGlowTracker));
94
didYouKnow.setDescription("");
96
didYouKnow.addMouseListener(new MouseAdapter() {
98
public void mouseEntered(MouseEvent e) {
99
iconGlowTracker.play();
103
public void mouseExited(MouseEvent e) {
104
iconGlowTracker.cancel();
108
mainPane.add("North", didYouKnow);
110
tipArea = new JPanel(new BorderLayout());
111
tipArea.setOpaque(false);
112
tipArea.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
113
tipArea.setBackground(UIManager.getColor("TextArea.background"));
114
mainPane.add("Center", tipArea);
116
tipPane.add("Center", mainPane);