1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.gscg.gameleader.dialogs.content.components;
15
16 import info.clearthought.layout.TableLayout;
17 import info.clearthought.layout.TableLayoutConstants;
18
19 import java.awt.Color;
20
21 import javax.swing.JLabel;
22 import javax.swing.JPanel;
23 import javax.swing.SwingConstants;
24
25 import nl.tudelft.simulation.logger.Logger;
26 import nl.tudelft.simulation.supplychain.content.Content;
27
28 import org.gscg.gameleader.dialogs.components.AbstractPanel;
29
30 /***
31 *
32 * The NamePanel is used to display the name of an actor.
33 * <p>
34 *
35 * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
36 * Delft, the Netherlands. All rights reserved.
37 *
38 * See for project information <a href="http://www.simulation.tudelft.nl/">
39 * www.simulation.tudelft.nl </a>.
40 *
41 * The source code and binary code of this software is proprietary information
42 * of Delft University of Technology.
43 *
44 * @author <a
45 * href="http://www.tbm.tudelft.nl/webstaf/stijnh/index.htm">Stijn-Pieter
46 * van Houten </a>
47 * @version $Revision: 1.1 $ $Date: 2005/06/16 12:33:57 $
48 * @since 1.0.3
49 */
50 public class NamePanel extends AbstractPanel
51 {
52 /*** the serial version uid */
53 private static final long serialVersionUID = 11L;
54
55 /*** the content */
56 private Content content = null;
57
58 /***
59 * constructs a new NamePanel
60 *
61 * @param content the content
62 */
63 public NamePanel(final Object content)
64 {
65 super("general information");
66 try
67 {
68 this.content = (Content) content;
69 } catch (Exception exception)
70 {
71
72 exception = null;
73 }
74 if (this.content != null)
75 {
76 this.initialize();
77 } else
78 {
79 Logger.severe(this, "<init>",
80 "Could not extract content from received content of class: "
81 + content.getClass());
82 }
83 }
84
85 /***
86 * @see org.gscg.gameleader.dialogs.components.AbstractPanel#initialize()
87 */
88 protected void initialize()
89 {
90 JPanel nameLabelPanel = new JPanel();
91
92 double[][] nameLabelPanelLayout = {
93 {TableLayoutConstants.FILL, TableLayoutConstants.FILL},
94 {20, 20}};
95 nameLabelPanel.setLayout(new TableLayout(nameLabelPanelLayout));
96 nameLabelPanel.setBackground(Color.WHITE);
97
98 JLabel senderLabel = super.getFormattedLabel("sender name");
99 nameLabelPanel.add(senderLabel, "0,0,L,C");
100
101 JLabel senderNameLabel = super.getFormattedLabel(this.content
102 .getSender().getName());
103 senderNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
104 nameLabelPanel.add(senderNameLabel, "1,0,R,C");
105
106 JLabel receiverLabel = super.getFormattedLabel("receiver name");
107 nameLabelPanel.add(receiverLabel, "0,1,L,C");
108
109 JLabel receiverNameLabel = super.getFormattedLabel(this.content
110 .getReceiver().getName());
111 receiverNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
112 nameLabelPanel.add(receiverNameLabel, "1,1,R,C");
113
114
115 double[][] panelLayout = {{TableLayoutConstants.FILL}, {40}};
116 super.setLayout(new TableLayout(panelLayout));
117
118
119 super.add(nameLabelPanel, "0,0,L,C");
120
121
122
123 super.validate();
124 super.doLayout();
125 }
126 }