001: /*
002: * $Id: WindowsTipOfTheDayUI.java,v 1.3 2005/10/10 18:02:24 rbair Exp $
003: *
004: * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
005: * Santa Clara, California 95054, U.S.A. All rights reserved.
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
020: */
021: package org.jdesktop.swingx.plaf.windows;
022:
023: import java.awt.BorderLayout;
024: import java.awt.Color;
025: import java.awt.Component;
026: import java.awt.Dimension;
027: import java.awt.Font;
028: import java.awt.Graphics;
029: import java.awt.Insets;
030:
031: import javax.swing.BorderFactory;
032: import javax.swing.JComponent;
033: import javax.swing.JDialog;
034: import javax.swing.JLabel;
035: import javax.swing.JPanel;
036: import javax.swing.UIManager;
037: import javax.swing.border.Border;
038: import javax.swing.border.CompoundBorder;
039: import javax.swing.plaf.ComponentUI;
040:
041: import org.jdesktop.swingx.JXTipOfTheDay;
042: import org.jdesktop.swingx.JXTipOfTheDay.ShowOnStartupChoice;
043: import org.jdesktop.swingx.plaf.basic.BasicTipOfTheDayUI;
044:
045: /**
046: * Windows implementation of the TipOfTheDayUI.
047: *
048: * @author <a href="mailto:fred@L2FProd.com">Frederic Lavigne</a>
049: */
050: public class WindowsTipOfTheDayUI extends BasicTipOfTheDayUI {
051:
052: public static ComponentUI createUI(JComponent c) {
053: return new WindowsTipOfTheDayUI((JXTipOfTheDay) c);
054: }
055:
056: public WindowsTipOfTheDayUI(JXTipOfTheDay tipPane) {
057: super (tipPane);
058: }
059:
060: @Override
061: public JDialog createDialog(Component parentComponent,
062: final ShowOnStartupChoice choice) {
063: return createDialog(parentComponent, choice, false);
064: }
065:
066: protected void installComponents() {
067: tipPane.setLayout(new BorderLayout());
068:
069: // tip icon
070: JLabel tipIcon = new JLabel();
071: tipIcon.setPreferredSize(new Dimension(60, 100));
072: tipIcon.setIcon(UIManager.getIcon("TipOfTheDay.icon"));
073: tipIcon.setHorizontalAlignment(JLabel.CENTER);
074: tipIcon.setVerticalAlignment(JLabel.TOP);
075: tipIcon.setBorder(BorderFactory.createEmptyBorder(24, 0, 0, 0));
076: tipPane.add("West", tipIcon);
077:
078: // tip area
079: JPanel rightPane = new JPanel(new BorderLayout());
080: JLabel didYouKnow = new JLabel(UIManager
081: .getString("TipOfTheDay.didYouKnowText"));
082: didYouKnow.setPreferredSize(new Dimension(50, 32));
083: didYouKnow.setOpaque(true);
084: didYouKnow.setBackground(UIManager
085: .getColor("TextArea.background"));
086: didYouKnow.setBorder(new CompoundBorder(
087: BorderFactory.createMatteBorder(0, 0, 2, 0, tipPane
088: .getBackground()), BorderFactory
089: .createEmptyBorder(4, 4, 4, 4)));
090: didYouKnow.setFont(tipPane.getFont().deriveFont(Font.BOLD, 15));
091: rightPane.add("North", didYouKnow);
092:
093: tipArea = new JPanel(new BorderLayout());
094: tipArea.setOpaque(true);
095: tipArea.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
096: tipArea
097: .setBackground(UIManager
098: .getColor("TextArea.background"));
099: rightPane.add("Center", tipArea);
100:
101: tipPane.add("Center", rightPane);
102: }
103:
104: public static class TipAreaBorder implements Border {
105: public Insets getBorderInsets(Component c) {
106: return new Insets(2, 2, 2, 2);
107: }
108:
109: public boolean isBorderOpaque() {
110: return false;
111: }
112:
113: public void paintBorder(Component c, Graphics g, int x, int y,
114: int width, int height) {
115: g.setColor(UIManager.getColor("TipOfTheDay.background"));
116: g.drawLine(x, y, x + width - 1, y);
117: g.drawLine(x, y, x, y + height - 1);
118:
119: g.setColor(Color.black);
120: g.drawLine(x + 1, y + 1, x + width - 3, y + 1);
121: g.drawLine(x + 1, y + 1, x + 1, y + height - 3);
122:
123: g.setColor(Color.white);
124: g.drawLine(x, y + height - 1, x + width, y + height - 1);
125: g.drawLine(x + width - 1, y, x + width - 1, y + height - 1);
126: }
127: }
128:
129: }
|