/*
 * Copyright 2006-2011 The MZmine 2 Development Team
 * 
 * This file is part of MZmine 2.
 * 
 * MZmine 2 is free software; you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 * 
 * MZmine 2 is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * MZmine 2; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
 * Fifth Floor, Boston, MA 02110-1301 USA
 */

package net.sf.mzmine.parameters.parametertypes;

import java.text.NumberFormat;

import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 */
public class PercentComponent extends JPanel {

	private JFormattedTextField percentField;

	public PercentComponent() {

		percentField = new JFormattedTextField(NumberFormat.getNumberInstance());
		percentField.setColumns(4);
		add(percentField);

		add(new JLabel("%"));

	}

	public void setValue(double value) {
		percentField.setValue(value * 100);
	}

	public Double getValue() {
		Number value = (Number) percentField.getValue();
		if (value == null)
			return null;
		return value.doubleValue() / 100;
	}

}

@@ -859,67 +859,22 @@
 java
-.text.NumberFormat;%0A%0Aimport javax.swing.JFormattedTextFi
+x.swing.JLab
 el
-d
 ;%0Aim
@@ -883,35 +883,35 @@
 rt javax.swing.J
-Lab
+Pan
 el;%0Aimport javax
@@ -918,21 +918,25 @@
 .swing.J
-Pan
+TextFi
 el
+d
 ;%0A%0A/**%0A 
@@ -996,25 +996,16 @@
 rivate J
-Formatted
 TextFiel
@@ -1077,17 +1077,8 @@
 ew J
-Formatted
 Text
@@ -1087,40 +1087,8 @@
 eld(
-NumberFormat.getNumberInstance()
 );%0A%09
@@ -1211,29 +1211,43 @@
 %7B%0A%09%09
-percentField.setV
+String stringValue = String.v
 alue
+Of
 (val
@@ -1257,16 +1257,53 @@
 * 100);%0A
+%09%09percentField.setText(stringValue);%0A
 %09%7D%0A%0A%09pub
@@ -1332,31 +1332,28 @@
 %7B%0A%09%09
-Number value = (Number)
+String stringValue =
  per
@@ -1369,69 +1369,97 @@
 .get
-Value
+Text
 ();%0A%09%09
-if (value == null)%0A%09%09%09return null
+try %7B%0A%09%09%09double doubleValue = Double.parseDouble(stringValue) / 100
 ;%0A%09%09
+%09
 return 
-value.
 doub
@@ -1469,17 +1469,67 @@
 alue
-() / 100;
+;%0A%09%09%7D catch (NumberFormatException e) %7B%0A%09%09%09return null;%0A%09%09%7D
 %0A%09%7D%0A

Change percent parameter from JFormattedTextField to JTextField