KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > explorer > CosTrading > gui > AvailableServiceTypesBox


1 /*===========================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2003 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Sylvain Leblanc.
23 Contributor(s): ______________________________________.
24
25 ===========================================================================*/

26
27 package org.objectweb.openccm.explorer.CosTrading.gui;
28
29 /** The java API's imports */
30 import javax.swing.JComboBox JavaDoc;
31 import javax.swing.JLabel JavaDoc;
32 import javax.swing.Box JavaDoc;
33 import javax.swing.BoxLayout JavaDoc;
34 import javax.swing.SwingConstants JavaDoc;
35
36 import java.awt.Component JavaDoc;
37 import java.awt.Dimension JavaDoc;
38
39 /**
40  * A Box to display available service types in a combo box. This
41  * class also provides a way to register a listener in order to be
42  * notified of any change in the combo box.
43  *
44  * @author <a HREF="mailto:Sylvain.Leblanc@lifl.fr">Sylvain Leblanc</a>
45  * @version 0.1
46  */

47 public class AvailableServiceTypesBox extends Box JavaDoc {
48
49     // ==================================================================
50
//
51
// Internal state.
52
//
53
// ==================================================================
54

55     /** The combo box. */
56     protected JComboBox JavaDoc types_;
57
58     // ==================================================================
59
//
60
// Constructors.
61
//
62
// ==================================================================
63

64     /**
65      * Default constructor.
66      *
67      * @param label The label placed behind the combo box.
68      * @param available_types Available service types IDs.
69      */

70     public AvailableServiceTypesBox(String JavaDoc label, String JavaDoc[] available_types) {
71         super(BoxLayout.X_AXIS);
72         add(Box.createHorizontalGlue());
73         JLabel JavaDoc fieldLabel = new JLabel JavaDoc(label, SwingConstants.RIGHT);
74         fieldLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
75         fieldLabel.setAlignmentY(Component.CENTER_ALIGNMENT);
76         add(fieldLabel);
77         add(Box.createHorizontalStrut(5));
78         types_ = new JComboBox JavaDoc(available_types);
79         types_.setPreferredSize(new Dimension JavaDoc(225, 20));
80         types_.setMaximumSize(new Dimension JavaDoc(225, 20));
81         add(types_);
82     }
83
84     // ==================================================================
85
//
86
// Internal methods.
87
//
88
// ==================================================================
89

90     // ==================================================================
91
//
92
// Public methods.
93
//
94
// ==================================================================
95

96     /**
97      * Returns the specified service type.
98      *
99      * @return The service type selected in the combo box.
100      */

101     public String JavaDoc getTypeName() {
102         return (String JavaDoc)types_.getSelectedItem();
103     }
104
105     /**
106      * Adds a listener on the combo box.
107      *
108      * @param listener The listener to add in the combo box.
109      */

110     public void addItemListener(java.awt.event.ItemListener JavaDoc listener) {
111         types_.addItemListener(listener);
112     }
113 }
114
Popular Tags