KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jgoodies > forms > layout > TestComponent


1 /*
2  * Copyright (c) 2003 JGoodies Karsten Lentzsch. All Rights Reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * o Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  *
10  * o Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  *
14  * o Neither the name of JGoodies Karsten Lentzsch nor the names of
15  * its contributors may be used to endorse or promote products derived
16  * from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
27  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */

30
31 package com.jgoodies.forms.layout;
32
33 import java.awt.Component JavaDoc;
34 import java.awt.Dimension JavaDoc;
35
36 /**
37  * A component that is used in the layout tests. It is constructed
38  * with fixed minimum and preferred sizes.
39  *
40  * @author Karsten Lentzsch
41  * @version $Revision: 1.2 $
42  */

43 public final class TestComponent extends Component JavaDoc {
44     
45     /**
46      * Holds the component's minimum size that can be requested
47      * using <code>#getMinimumSize</code>.
48      */

49     private final Dimension JavaDoc minimumSize;
50
51     /**
52      * Holds the component's preferred size that can be requested
53      * using <code>#getPreferredSize</code>.
54      */

55     private final Dimension JavaDoc preferredSize;
56     
57     
58     // Instance Creation ******************************************************
59

60     /**
61      * Constructs a TestComponent with the given minimum and preferred sizes.
62      *
63      * @param minimumSize the component's minimum size
64      * @param preferredSize the component's preferred size
65      */

66     public TestComponent(Dimension JavaDoc minimumSize, Dimension JavaDoc preferredSize) {
67         this.minimumSize = minimumSize;
68         this.preferredSize = preferredSize;
69     }
70     
71     /**
72      * Constructs a TestComponent with the given minimum and preferred
73      * widths and heights.
74      *
75      * @param minWidth the component's minimum width
76      * @param minHeight the component's minimum height
77      * @param prefWidth the component's preferred width
78      * @param prefHeight the component's preferred height
79      */

80     public TestComponent(int minWidth, int minHeight, int prefWidth, int prefHeight) {
81         this(new Dimension JavaDoc(minWidth, minHeight),
82              new Dimension JavaDoc(prefWidth, prefHeight));
83     }
84     
85     
86     // Accessing Properties ***************************************************
87

88     /**
89      * Returns the minimum size of this component.
90      *
91      * @return a dimension object indicating this component's minimum size
92      * @see #getPreferredSize
93      */

94     public Dimension JavaDoc getMinimumSize() {
95         return minimumSize;
96     }
97     
98     
99     /**
100      * Returns the preferred size of this component.
101      *
102      * @return a dimension object indicating this component's preferred size
103      * @see #getMinimumSize
104      */

105     public Dimension JavaDoc getPreferredSize() {
106         return preferredSize;
107     }
108     
109 }
110
Popular Tags