Author: sebb
Date: Wed Oct 31 07:56:08 2007
New Revision: 590697

URL: http://svn.apache.org/viewvc?rev=590697&view=rev
Log:
Tidy up; fix setEditable()

Modified:
    jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledChoice.java

Modified: 
jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledChoice.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledChoice.java?rev=590697&r1=590696&r2=590697&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledChoice.java 
(original)
+++ jakarta/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/JLabeledChoice.java 
Wed Oct 31 07:56:08 2007
@@ -38,12 +38,12 @@
 public class JLabeledChoice extends JPanel implements JLabeledField {
        private static final Object[] EMPTY_OBJECT_ARRAY = new Object [0];
 
-    private JLabel mLabel = new JLabel();
+    private final JLabel mLabel = new JLabel();
 
-       private JComboBox choiceList;
+       private final JComboBox choiceList;
 
        // Maybe move to vector if MT problems occur
-       private ArrayList mChangeListeners = new ArrayList(3);
+       private final ArrayList mChangeListeners = new ArrayList(3);
 
        private JButton delete, add;
 
@@ -56,13 +56,6 @@
                init();
        }
 
-       public List getComponentList() {
-               List comps = new LinkedList();
-               comps.add(mLabel);
-               comps.add(choiceList);
-               return comps;
-       }
-
        public JLabeledChoice(String pLabel, boolean editable) {
                super();
                choiceList = new JComboBox();
@@ -71,41 +64,52 @@
                init();
        }
 
-       public void setEditable(boolean editable) {
-               choiceList.setEditable(false);// TODO - is this correct?
-       }
-
-       public void addValue(String item) {
-               choiceList.addItem(item);
-       }
-
-       public void setValues(String[] items) {
-               choiceList.removeAllItems();
-               for (int i = 0; i < items.length; i++) {
-                       choiceList.addItem(items[i]);
-               }
-       }
-
        /**
-        * Constructs a new component with the label displaying the passed text.
+        * Constructs a non-edittable combo-box with the label displaying the 
passed text.
         * 
-        * @param pLabel
-        *            The text to in the label.
+        * @param pLabel - the text to display in the label.
+        * @param items - the items to display in the Combo box
         */
        public JLabeledChoice(String pLabel, String[] items) {
-               super();
-               mLabel.setText(pLabel);
-               choiceList = new JComboBox(items);
-               choiceList.setEditable(false);
-               init();
+               this(pLabel, items, false);
        }
 
+       /**
+        * Constructs a combo-box with the label displaying the passed text.
+        * 
+        * @param pLabel - the text to display in the label.
+        * @param items - the items to display in the Combo box
+        * @param editable - if true, then Add and Delete buttons are created.
+        * 
+        */
        public JLabeledChoice(String pLabel, String[] items, boolean editable) {
                super();
                mLabel.setText(pLabel);
                choiceList = new JComboBox(items);
                choiceList.setEditable(editable);
                init();
+       }
+
+       public List getComponentList() {
+               List comps = new LinkedList();
+               comps.add(mLabel);
+               comps.add(choiceList);
+               return comps;
+       }
+
+       public void setEditable(boolean editable) {
+               choiceList.setEditable(editable);
+       }
+
+       public void addValue(String item) {
+               choiceList.addItem(item);
+       }
+
+       public void setValues(String[] items) {
+               choiceList.removeAllItems();
+               for (int i = 0; i < items.length; i++) {
+                       choiceList.addItem(items[i]);
+               }
        }
 
        /**



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to