FileDocCategorySizeDatePackage
DoubleTransferValue.javaAPI Docmp4parser 1.0-RC-171175Wed Dec 19 20:10:21 GMT 2012com.coremedia.iso.gui.transferhelper

DoubleTransferValue.java

package com.coremedia.iso.gui.transferhelper;

import com.coremedia.iso.boxes.Box;

import javax.swing.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.ParseException;

/**
 * Created by IntelliJ IDEA.
 * User: sannies
 * Date: 11.11.2008
 * Time: 23:12:24
 * To change this template use File | Settings | File Templates.
 */
public class DoubleTransferValue implements TransferValue {
    JFormattedTextField source;
    Method writeMethod;
    Box box;

    public DoubleTransferValue(JFormattedTextField source, Box box, Method writeMethod) {
        this.source = source;
        this.writeMethod = writeMethod;
        this.box = box;
    }

    public void go() {
        try {
            writeMethod.invoke(box, ((Number) source.getFormatter().stringToValue(source.getText())).doubleValue());
        } catch (ParseException e) {
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }

    }
}