Exemple #1
0
 public static void main(String[] args) {
   // TODO Auto-generated method stub
   Converter f = new Converter("Metric Converter");
   f.setSize(400, 300);
   f.setVisible(true);
   f.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
 }
    /**
     * Updates the shared value instance if updateValue is true. Always forces the redraw of
     * everything.
     */
    protected void doValueUpdate(FilterBypass fb) throws BadLocationException {
      Document doc = fb.getDocument();
      String text = doc.getText(0, doc.getLength());
      if (text.isEmpty()) {
        text = "0";
      }

      if (updateValue == true) {
        try {
          Double value = new Double(text);
          double newValue = multiplier.getValueToBeSet(value.doubleValue());
          cValue.setValue(newValue);
        } catch (NumberFormatException e) {
          // do nothing, since we allow '-'
        }
      }
      topContainer.forceRedraw();
    }
Exemple #3
0
 /**
  * Registers a Converter with the ConverterLibrary
  *
  * @param converter <code>Converter</code> Instance of Converter able to convert Strings into
  *     objects of the given type
  */
 public void register(Converter<?> converter) {
   converters.put(converter.convertsTo(), converter);
 }