source: src/main/java/weka/gui/PropertyValueSelector.java @ 6

Last change on this file since 6 was 4, checked in by gnappo, 14 years ago

Import di weka.

File size: 1.9 KB
Line 
1/*
2 *    This program is free software; you can redistribute it and/or modify
3 *    it under the terms of the GNU General Public License as published by
4 *    the Free Software Foundation; either version 2 of the License, or
5 *    (at your option) any later version.
6 *
7 *    This program is distributed in the hope that it will be useful,
8 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
9 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 *    GNU General Public License for more details.
11 *
12 *    You should have received a copy of the GNU General Public License
13 *    along with this program; if not, write to the Free Software
14 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 */
16
17/*
18 *    PropertyValueSelector.java
19 *    Copyright (C) 1999 University of Waikato, Hamilton, New Zealand
20 *
21 */
22
23package weka.gui;
24
25import java.beans.PropertyEditor;
26
27import javax.swing.ComboBoxModel;
28import javax.swing.DefaultComboBoxModel;
29import javax.swing.JComboBox;
30
31/**
32 * Support for any PropertyEditor that uses tags.
33 *
34 * @author Len Trigg (trigg@cs.waikato.ac.nz)
35 * @version $Revision: 1.7 $
36 */
37class PropertyValueSelector
38  extends JComboBox {
39
40  /** for serialization */
41  private static final long serialVersionUID = 128041237745933212L;
42
43  /** The property editor */
44  PropertyEditor m_Editor;
45 
46  /**
47   * Sets up the editing component with the supplied editor.
48   *
49   * @param pe the PropertyEditor
50   */
51  public PropertyValueSelector(PropertyEditor pe) {
52     
53    m_Editor = pe;
54    Object value = m_Editor.getAsText();
55    String tags[] = m_Editor.getTags();
56    ComboBoxModel model = new DefaultComboBoxModel(tags) {
57      private static final long serialVersionUID = 7942587653040180213L;
58     
59      public Object getSelectedItem() {
60        return m_Editor.getAsText();
61      }
62      public void setSelectedItem(Object o) {
63        m_Editor.setAsText((String)o);
64      }
65    };
66    setModel(model);
67    setSelectedItem(value);
68  }
69}
70
71
Note: See TracBrowser for help on using the repository browser.