KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > explorer > menu > LabelBox


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): Jerome Moroy.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26 package org.objectweb.openccm.explorer.menu;
27
28 /** The java API's imports */
29 import javax.swing.JTextField JavaDoc;
30 import javax.swing.JLabel JavaDoc;
31 import javax.swing.Box JavaDoc;
32 import javax.swing.BoxLayout JavaDoc;
33 import javax.swing.SwingConstants JavaDoc;
34
35 import java.awt.Component JavaDoc;
36 import java.awt.Dimension JavaDoc;
37
38 /**
39  * This class represents the panel which allows to specify a label.
40  *
41  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jerome Moroy</a>
42  *
43  * @version 0.1
44  */

45 public class LabelBox extends Box JavaDoc {
46
47     //TODO: Maybe obsolete !!!
48

49     /** The name of the entry */
50     protected JTextField JavaDoc name_;
51
52     /** The label of the entry */
53     protected JLabel JavaDoc fieldLabel_;
54
55     /**
56      * Default constructor
57      */

58     public LabelBox(String JavaDoc label, String JavaDoc initValue) {
59         super(BoxLayout.X_AXIS);
60         add(Box.createHorizontalGlue());
61         fieldLabel_ = new JLabel JavaDoc(label, SwingConstants.RIGHT);
62         fieldLabel_.setAlignmentX(Component.RIGHT_ALIGNMENT);
63         fieldLabel_.setAlignmentY(Component.CENTER_ALIGNMENT);
64         add(fieldLabel_);
65         add(Box.createHorizontalStrut(5));
66         name_ = new JTextField JavaDoc(initValue);
67         name_.setPreferredSize(new Dimension JavaDoc(225, 20));
68         name_.setMaximumSize(new Dimension JavaDoc(225, 20));
69         add(name_);
70     }
71
72     /**
73      * Default constructor
74      */

75     public LabelBox(String JavaDoc label) {
76         this(label, "");
77     }
78
79     public void addActionListener(java.awt.event.ActionListener JavaDoc listener) {
80         name_.addActionListener(listener);
81     }
82
83     /** Returns the specify label */
84     public String JavaDoc getLabel() {
85         return name_.getText();
86     }
87
88     /**
89      * Sets the tool tip text on each JComponent of the box.
90      *
91      * @param text The tool tip text to set.
92      */

93     public void setToolTipText(String JavaDoc text) {
94         name_.setToolTipText(text);
95         fieldLabel_.setToolTipText(text);
96     }
97
98     /**
99      * Gets the tool tip text set on each JComponent of the box.
100      *
101      * @return The tool tip text used.
102      */

103     public String JavaDoc getToolTipText() {
104         return name_.getToolTipText();
105     }
106 }
107
Popular Tags