1 26 27 package org.objectweb.openccm.explorer.CosTrading.gui; 28 29 30 import javax.swing.JComboBox ; 31 import javax.swing.SwingConstants ; 32 import javax.swing.BoxLayout ; 33 import javax.swing.Box ; 34 import javax.swing.JLabel ; 35 36 import java.awt.Component ; 37 import java.awt.Dimension ; 38 39 47 public class BooleanBox extends Box { 48 49 55 56 protected JComboBox bool_combo_; 57 58 59 protected JLabel fieldLabel_; 60 61 67 73 public BooleanBox(String label, boolean init) { 74 super(BoxLayout.X_AXIS); 75 add(Box.createHorizontalGlue()); 76 fieldLabel_ = new JLabel (label, SwingConstants.RIGHT); 77 fieldLabel_.setAlignmentX(Component.RIGHT_ALIGNMENT); 78 fieldLabel_.setAlignmentY(Component.CENTER_ALIGNMENT); 79 add(fieldLabel_); 80 add(Box.createHorizontalStrut(5)); 81 bool_combo_ = new JComboBox (new String [] {"true", "false"}); 82 bool_combo_.setSelectedIndex(init?0:1); 83 bool_combo_.setPreferredSize(new Dimension (225, 20)); 84 bool_combo_.setMaximumSize(new Dimension (225, 20)); 85 add(bool_combo_); 86 } 87 88 93 public BooleanBox(String label) { 94 this(label, true); 95 } 96 97 103 109 114 public void addItemListener(java.awt.event.ItemListener listener) { 115 bool_combo_.addItemListener(listener); 116 } 117 118 123 public boolean getBoolean() { 124 String bool = (String )bool_combo_.getSelectedItem(); 125 if (bool.equals("true")) return true; 126 return false; 127 } 128 129 135 140 public void setToolTipText(String text) { 141 bool_combo_.setToolTipText(text); 142 fieldLabel_.setToolTipText(text); 143 } 144 145 150 public String getToolTipText() { 151 return bool_combo_.getToolTipText(); 152 } 153 } 154 155 | Popular Tags |