aboutsummaryrefslogtreecommitdiff
path: root/src/uk/org/ury/frontend/FrontendBanner.java
blob: b717c3769088b5ce3ad104b69b864f0c99774006 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package uk.org.ury.frontend;

import java.awt.FlowLayout;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.UIManager;


/**
 * A banner, displaying a title, intended for use at the top of the 
 * frontend frame.
 * 
 * @author  Matt Windsor
 */

public class FrontendBanner extends JPanel
{
  /**
   * 
   */
  private static final long serialVersionUID = -3636933349004358394L;

  private static final String TITLE_PREFIX = "<html><h1>";
  private static final String TITLE_SUFFIX = "</h1></html>";
  
  private JLabel titleLabel;
  
  
  /**
   * Construct a new banner.
   * 
   * @param title  The initial title to display in the banner.
   */
  
  public
  FrontendBanner (String title)
  {
    setLayout (new FlowLayout (FlowLayout.LEFT));
    setBackground (UIManager.getColor ("textHighlight"));
    setOpaque (true);
    
    JLabel logo = new JLabel (new ImageIcon (getClass ().getResource ("images/ury.png")));
    
    
    titleLabel = new JLabel (TITLE_PREFIX + title + TITLE_SUFFIX);
    titleLabel.setBorder (BorderFactory.createEmptyBorder (0, 15, 0, 0));
    titleLabel.setForeground (UIManager.getColor ("textHighlightText"));

    
    add (logo);
    add (titleLabel);
  }
  
  
  /**
   * Change the title displayed on the banner.
   * 
   * @param title  The new title to display.
   */
  
  public void
  setTitle (String title)
  {
   titleLabel.setText (TITLE_PREFIX + title + TITLE_SUFFIX); 
  }
}