1 26 package org.objectweb.openccm.explorer.menu; 27 28 29 import javax.swing.JTextField ; 30 import javax.swing.JLabel ; 31 import javax.swing.Box ; 32 import javax.swing.BoxLayout ; 33 import javax.swing.SwingConstants ; 34 35 import java.awt.Component ; 36 import java.awt.Dimension ; 37 38 45 public class LabelBox extends Box { 46 47 49 50 protected JTextField name_; 51 52 53 protected JLabel fieldLabel_; 54 55 58 public LabelBox(String label, String initValue) { 59 super(BoxLayout.X_AXIS); 60 add(Box.createHorizontalGlue()); 61 fieldLabel_ = new JLabel (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 (initValue); 67 name_.setPreferredSize(new Dimension (225, 20)); 68 name_.setMaximumSize(new Dimension (225, 20)); 69 add(name_); 70 } 71 72 75 public LabelBox(String label) { 76 this(label, ""); 77 } 78 79 public void addActionListener(java.awt.event.ActionListener listener) { 80 name_.addActionListener(listener); 81 } 82 83 84 public String getLabel() { 85 return name_.getText(); 86 } 87 88 93 public void setToolTipText(String text) { 94 name_.setToolTipText(text); 95 fieldLabel_.setToolTipText(text); 96 } 97 98 103 public String getToolTipText() { 104 return name_.getToolTipText(); 105 } 106 } 107 | Popular Tags |