KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > gui > util > VerticalPanel


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/gui/util/VerticalPanel.java,v 1.5 2004/02/14 03:34:29 sebb Exp $
2
/*
3  * Copyright 2003-2004 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17 */

18
19 /*
20  * Created on Apr 25, 2003
21  *
22  * To change the template for this generated file go to
23  * Window>Preferences>Java>Code Generation>Code and Comments
24  */

25 package org.apache.jmeter.gui.util;
26
27 import java.awt.BorderLayout JavaDoc;
28 import java.awt.Component JavaDoc;
29
30 import javax.swing.Box JavaDoc;
31 import javax.swing.JComponent JavaDoc;
32 import javax.swing.JPanel JavaDoc;
33
34 /**
35  * @author ano ano
36  * @version $Revision: 1.5 $
37  */

38 public class VerticalPanel extends JPanel JavaDoc
39 {
40     private Box JavaDoc subPanel = Box.createVerticalBox();
41     private float horizontalAlign;
42     private int vgap;
43     
44     public VerticalPanel()
45     {
46         this(5, LEFT_ALIGNMENT);
47     }
48     
49     public VerticalPanel(int vgap, float horizontalAlign)
50     {
51         super(new BorderLayout JavaDoc());
52         add(subPanel,BorderLayout.NORTH);
53         this.vgap = vgap;
54         this.horizontalAlign = horizontalAlign;
55     }
56     
57     /* (non-Javadoc)
58      * @see java.awt.Container#add(java.awt.Component)
59      */

60     public Component JavaDoc add(Component JavaDoc c)
61     {
62         // This won't work right if we remove components. But we don't, so I'm
63
// not going to worry about it right now.
64
if (vgap > 0 && subPanel.getComponentCount() > 0)
65         {
66             subPanel.add(Box.createVerticalStrut(vgap));
67         }
68         
69         if (c instanceof JComponent JavaDoc)
70         {
71             ((JComponent JavaDoc)c).setAlignmentX(horizontalAlign);
72         }
73         
74         return subPanel.add(c);
75     }
76 }
77
Popular Tags