001: /**
002: * L2FProd.com Common Components 7.3 License.
003: *
004: * Copyright 2005-2007 L2FProd.com
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */package com.l2fprod.common.swing;
018:
019: import java.awt.BorderLayout;
020: import java.awt.Color;
021: import java.awt.Dimension;
022:
023: import javax.swing.Icon;
024: import javax.swing.JEditorPane;
025: import javax.swing.JLabel;
026: import javax.swing.JPanel;
027: import javax.swing.UIManager;
028: import javax.swing.border.CompoundBorder;
029: import javax.swing.border.EtchedBorder;
030: import javax.swing.text.JTextComponent;
031:
032: /**
033: * BannerPanel. <br>
034: *
035: */
036: public class BannerPanel extends JPanel {
037:
038: private JLabel titleLabel;
039:
040: private JTextComponent subtitleLabel;
041:
042: private JLabel iconLabel;
043:
044: public BannerPanel() {
045: setBorder(new CompoundBorder(new EtchedBorder(),
046: LookAndFeelTweaks.PANEL_BORDER));
047:
048: setOpaque(true);
049: setBackground(UIManager.getColor("Table.background"));
050:
051: titleLabel = new JLabel();
052: titleLabel.setOpaque(false);
053:
054: subtitleLabel = new JEditorPane("text/html", "<html>");
055: subtitleLabel.setFont(titleLabel.getFont());
056:
057: LookAndFeelTweaks.makeBold(titleLabel);
058: LookAndFeelTweaks.makeMultilineLabel(subtitleLabel);
059: LookAndFeelTweaks.htmlize(subtitleLabel);
060:
061: iconLabel = new JLabel();
062: iconLabel.setPreferredSize(new Dimension(50, 50));
063:
064: setLayout(new BorderLayout());
065:
066: JPanel nestedPane = new JPanel(new BorderLayout());
067: nestedPane.setOpaque(false);
068: nestedPane.add("North", titleLabel);
069: nestedPane.add("Center", subtitleLabel);
070: add("Center", nestedPane);
071: add("East", iconLabel);
072: }
073:
074: public void setTitleColor(Color color) {
075: titleLabel.setForeground(color);
076: }
077:
078: public Color getTitleColor() {
079: return titleLabel.getForeground();
080: }
081:
082: public void setSubtitleColor(Color color) {
083: subtitleLabel.setForeground(color);
084: }
085:
086: public Color getSubtitleColor() {
087: return subtitleLabel.getForeground();
088: }
089:
090: public void setTitle(String title) {
091: titleLabel.setText(title);
092: }
093:
094: public String getTitle() {
095: return titleLabel.getText();
096: }
097:
098: public void setSubtitle(String subtitle) {
099: subtitleLabel.setText(subtitle);
100: }
101:
102: public String getSubtitle() {
103: return subtitleLabel.getText();
104: }
105:
106: public void setSubtitleVisible(boolean b) {
107: subtitleLabel.setVisible(b);
108: }
109:
110: public boolean isSubtitleVisible() {
111: return subtitleLabel.isVisible();
112: }
113:
114: public void setIcon(Icon icon) {
115: iconLabel.setIcon(icon);
116: }
117:
118: public Icon getIcon() {
119: return iconLabel.getIcon();
120: }
121:
122: public void setIconVisible(boolean b) {
123: iconLabel.setVisible(b);
124: }
125:
126: public boolean isIconVisible() {
127: return iconLabel.isVisible();
128: }
129:
130: }
|