File Source: TitlePanel.java
/*
P/P * Method: com.dmdirc.addons.ui_swing.components.TitlePanel__static_init
*/
1 /*
2 *
3 * Copyright (c) 2006-2008 Chris Smith, Shane Mc Cormack, Gregory Holmes
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24 package com.dmdirc.addons.ui_swing.components;
25
26 import java.awt.Color;
27
28 import javax.swing.BorderFactory;
29 import javax.swing.JLabel;
30 import javax.swing.JPanel;
31 import javax.swing.border.Border;
32
33 import net.miginfocom.swing.MigLayout;
34
35 /**
36 * Displays a title panel.
37 */
38 public class TitlePanel extends JPanel {
39
40 /**
41 * A version number for this class. It should be changed whenever the
42 * class structure is changed (or anything else that would prevent
43 * serialized objects being unserialized with the new class).
44 */
45 private static final long serialVersionUID = -4026633984970698130L;
46 /** Title label. */
47 private JLabel title;
48 /** Title border. */
49 final Border border;
50
51 /**
52 * Instantiates a new title panel.
53 *
54 * @param border Border to use for the panel
55 */
56 public TitlePanel(final Border border) {
/*
P/P * Method: void com.dmdirc.addons.ui_swing.components.TitlePanel(Border)
*
* Postconditions:
* this.border == border
* init'ed(this.border)
* this.title == &new JLabel(TitlePanel#2)
* new JLabel(TitlePanel#2) num objects == 1
*/
57 this(border, "");
58 }
59
60 /**
61 * Instantiates a new title panel.
62 *
63 * @param text Initial text
64 */
65 public TitlePanel(final String text) {
/*
P/P * Method: void com.dmdirc.addons.ui_swing.components.TitlePanel(String)
*
* Presumptions:
* init'ed(java.awt.Color.BLACK)
*
* Postconditions:
* init'ed(this.border)
* this.title == &new JLabel(TitlePanel#2)
* new JLabel(TitlePanel#2) num objects == 1
*/
66 this(BorderFactory.createLineBorder(Color.BLACK), text);
67 }
68
69 /**
70 * Instantiates a new title panel.
71 *
72 * @param border Border to use for the panel
73 * @param text Initial text
74 */
75 public TitlePanel(final Border border, final String text) {
/*
P/P * Method: void com.dmdirc.addons.ui_swing.components.TitlePanel(Border, String)
*
* Presumptions:
* init'ed(java.awt.Color.WHITE)
* javax.swing.JLabel:getFont(...)@81 != null
*
* Postconditions:
* this.border == border
* init'ed(this.border)
* this.title == &new JLabel(TitlePanel#2)
* new JLabel(TitlePanel#2) num objects == 1
*/
76 super(new MigLayout());
77
78 this.border = border;
79
80 title = new JLabel(text);
81 title.setFont(title.getFont().deriveFont((float) (title.getFont().
82 getSize() * 1.5)));
83
84 add(title, "grow, push");
85 setBorder(border);
86 setBackground(Color.WHITE);
87 }
88
89 /**
90 * Sets the text of this title panel.
91 *
92 * @param text New title text.
93 */
94 public void setText(final String text) {
/*
P/P * Method: void setText(String)
*
* Preconditions:
* this.title != null
*/
95 title.setText(text);
96 }
97 }
SofCheck Inspector Build Version : 2.17854
| TitlePanel.java |
2009-Jun-25 01:54:24 |
| TitlePanel.class |
2009-Sep-02 17:04:15 |