File Source: TitlePanel.java
/*
P/P * Method: com.dmdirc.installer.ui.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.installer.ui;
25
26 import com.dmdirc.installer.Step;
27 import com.dmdirc.installer.ui.EtchedLineBorder.BorderSide;
28
29 import java.awt.BorderLayout;
30 import java.awt.Color;
31
32 import javax.swing.ImageIcon;
33 import javax.swing.JLabel;
34 import javax.swing.JPanel;
35 import javax.swing.border.EtchedBorder;
36
37 /**
38 * Simple title panel for a wizard.
39 */
40 public class TitlePanel extends JPanel {
41
42 private static final long serialVersionUID = 7173184984913948951L;
43 private final JLabel title;
44 private final JLabel image;
45
46 /**
47 * Instantiates a new title panel.
48 *
49 * @param step Initial title text
50 */
51 public TitlePanel(final Step step) {
/*
P/P * Method: void com.dmdirc.installer.ui.TitlePanel(Step)
*
* Presumptions:
* init'ed(java.awt.Color.WHITE)
* javax.swing.JLabel:getFont(...)@59 != null
*
* Postconditions:
* this.image == &new JLabel(TitlePanel#3)
* this.title == &new JLabel(TitlePanel#2)
* new JLabel(TitlePanel#2) num objects == 1
* new JLabel(TitlePanel#3) num objects == 1
*/
52 super(new BorderLayout());
53
54 title = new JLabel();
55 image = new JLabel();
56
57 setStep(step);
58
59 title.setFont(title.getFont().deriveFont((float) (title.getFont().
60 getSize() * 1.5)));
61 add(title, BorderLayout.CENTER);
62 add(image, BorderLayout.EAST);
63 setBackground(Color.WHITE);
64 setBorder(new EtchedLineBorder(EtchedBorder.RAISED, BorderSide.BOTTOM));
65 }
66
67 /**
68 * Sets the title text.
69 *
70 * @param step new title text
71 */
72 public void setStep(final Step step) {
/*
P/P * Method: void setStep(Step)
*
* Preconditions:
* this.image != null
* this.title != null
*
* Test Vectors:
* step: Inverse{null}, Addr_Set{null}
* java.lang.String:equals(...)@79: {0}, {1}
*/
73 if (step == null) {
74 title.setText("");
75 image.setIcon(null);
76 return;
77 }
78
79 if ("".equals(step.getStepDescription())) {
80 title.setText(step.getStepName());
81 } else {
82 title.setText(step.getStepName() + "\n" + step.getStepDescription());
83 }
84 if (step.getIcon() == null) {
85 image.setIcon(null);
86 } else {
87 image.setIcon(new ImageIcon(step.getIcon()));
88 }
89 }
90 }
SofCheck Inspector Build Version : 2.17854
| TitlePanel.java |
2009-Jun-25 01:54:24 |
| TitlePanel.class |
2009-Sep-02 17:04:16 |