KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > metadata > range > swing > relatedevents > RelatedEventHeadingPanel


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.him.metadata.range.swing.relatedevents;
20
21 import java.awt.*;
22 import java.util.*;
23 import java.util.Iterator JavaDoc;
24
25 import javax.swing.*;
26 import javax.swing.JPanel JavaDoc;
27
28 /**
29  * @author Michael Bell
30  * @version $Revision: 1.1 $
31  *
32  */

33 public class RelatedEventHeadingPanel extends JPanel JavaDoc {
34
35     int m_nDateWidth = 0;
36     int m_nRelationshipWidth = 0;
37     int m_nTextWidth = 0;
38
39     /**
40      *
41      */

42     public RelatedEventHeadingPanel(int nDateWidth, int nRelnWidth, int nTextWidth) {
43         super();
44         m_nDateWidth = nDateWidth;
45         m_nRelationshipWidth = nRelnWidth;
46         m_nTextWidth = nTextWidth;
47         
48         setup();
49     }
50
51     /**
52      *
53      */

54     private void setup() {
55         FlowLayout layout = new FlowLayout(FlowLayout.CENTER,RelatedEventValueDisplay.m_nSpace,0);
56         
57         this.setLayout(layout);
58         ArrayList comps = new ArrayList();
59         
60         String JavaDoc fontName = "Dialog";
61         int fontSize = 13;
62         Font font = new Font(fontName, Font.BOLD, fontSize);
63         
64         JLabel startDate = new JLabel("Start Date");
65         startDate.setFont(font);
66                         
67         Dimension dim = startDate.getPreferredSize();
68         int nLabelHeight = dim.height;
69         Dimension dateDim = new Dimension(m_nDateWidth,nLabelHeight);
70         startDate.setPreferredSize(dateDim);
71         startDate.setHorizontalAlignment(SwingConstants.CENTER);
72         this.add(startDate);
73         comps.add(startDate);
74         JLabel endDate = new JLabel("End Date");
75         endDate.setFont(font);
76         endDate.setHorizontalAlignment(SwingConstants.CENTER);
77         
78         endDate.setPreferredSize(dateDim);
79         this.add(endDate);
80         comps.add(endDate);
81         
82         Dimension relnDim = new Dimension(m_nRelationshipWidth,nLabelHeight);
83         
84         JLabel type = new JLabel("Type");
85         type.setFont(font);
86         type.setPreferredSize(relnDim);
87         type.setHorizontalAlignment(SwingConstants.CENTER);
88
89         this.add(type);
90         comps.add(type);
91         
92         JLabel text = new JLabel("Text");
93         text.setFont(font);
94         Dimension textDim = new Dimension(m_nTextWidth,nLabelHeight);
95         text.setPreferredSize(textDim);
96         text.setHorizontalAlignment(SwingConstants.CENTER);
97         
98         this.add(text);
99         comps.add(text);
100         
101         JLabel people = new JLabel("People");
102         people.setFont(font);
103         people.setPreferredSize(relnDim);
104         people.setHorizontalAlignment(SwingConstants.CENTER);
105         this.add(people);
106         comps.add(people);
107         JLabel place = new JLabel("Place");
108         place.setFont(font);
109         place.setPreferredSize(relnDim);
110         place.setHorizontalAlignment(SwingConstants.CENTER);
111
112         this.add(place);
113         comps.add(place);
114         
115         
116         int nWidth = 0;
117         
118         Iterator JavaDoc iter = comps.iterator();
119         
120         while (iter.hasNext()) {
121             Component comp = (Component) iter.next();
122             nWidth = nWidth + comp.getPreferredSize().width;
123         }
124         
125         
126         
127     }
128
129
130
131 }
132
Popular Tags