View Javadoc

1   // Copyright 2003, FreeHEP.
2   package org.freehep.graphicsio.exportchooser;
3   
4   import java.util.Properties;
5   
6   import javax.swing.JTextField;
7   
8   /**
9    * 
10   * @author Mark Donszelmann
11   * @version $Id: OptionTextField.java 8584 2006-08-10 23:06:37Z duns $
12   */
13  public class OptionTextField extends JTextField implements Options {
14      protected String initialText;
15  
16      protected String key;
17  
18      public OptionTextField(Properties options, String key, int columns) {
19          super(options.getProperty(key, ""), columns);
20          this.key = key;
21          initialText = getText();
22      }
23  
24      public boolean applyChangedOptions(Properties options) {
25          if (!getText().equals(initialText)) {
26              options.setProperty(key, getText());
27              return true;
28          }
29          return false;
30      }
31  }