Source code: recoin/gui/SubmitSubPanel.java
1
2 package recoin.gui;
3
4 import java.util.Vector;
5 import java.util.Enumeration;
6 import java.awt.GridLayout;
7 import java.awt.GridBagConstraints;
8 import javax.swing.JLabel;
9 import javax.swing.JPanel;
10 import recoin.util.SelfDescription;
11
12 /**
13 * The SubmitSubPanel displays a summary of the parameters chosen in the procedure
14 * it is part of. It is therefore the last panel to be shown to the user in a certain
15 * procedure. It implements the Writable interface to add the content before being
16 * displayed.
17 * @author Jan H. Scheufen
18 * @version 0.2.9
19 */
20 public class SubmitSubPanel extends ContentSubPanel implements Writable
21 {
22 /**
23 * The panels added to this SubmitSubPanel.
24 */
25 private Vector panels;
26
27 /**
28 * Creates a new SubmitSubPanel.
29 */
30 public SubmitSubPanel()
31 {
32 super();
33 panels = new Vector();
34 }
35
36 /**
37 * Adds the specified content to this SubmitSubPanel.
38 * @param name the name or header of the content.
39 * @param value the content.
40 * @see recoin.gui.Writable#addContent(java.lang.String, java.lang.String)
41 */
42 public void addContent(String name, String value)
43 {
44 JPanel p = new JPanel( new GridLayout(2,1) );
45 JLabel a = new JLabel( name );
46 JLabel b = new JLabel( value );
47 p.add( a );
48 p.add( b );
49 panels.add( p );
50 }
51
52 /**
53 * Adds the specified selfdescription to this SubmitSubPanel.
54 * @param name the name or header of the selfdescription.
55 * @param object the selfdescription.
56 * @see recoin.gui.Writable#addContent(java.lang.String, recoin.util.SelfDescription)
57 */
58 public void addContent(String name, SelfDescription object)
59 {
60 JPanel p = new JPanel( new GridLayout(2,1) );
61 JLabel a = new JLabel( name );
62 JLabel b = new JLabel( object.getSelfDescription() );
63 p.add( a );
64 p.add( b );
65 panels.add( p );
66 }
67
68 /**
69 * Renders the content of this SubmitSubPanel. This method should be called after
70 * calling one of the addContent() methods in order to update the layout.
71 */
72 public void renderContent()
73 {
74 int y;
75 Enumeration enum;
76 for( y=0, enum = panels.elements(); enum.hasMoreElements(); y++ )
77 {
78 GridBagConstraints gbc;
79 gbc = new GridBagConstraints();
80 gbc.gridx = 0;
81 gbc.gridy = y;
82 gbc.insets = new java.awt.Insets(5, 5, 5, 5);
83 gbc.anchor = java.awt.GridBagConstraints.WEST;
84 add( (JPanel)enum.nextElement(), gbc);
85 }
86 }
87 }