View Javadoc

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