Java tutorial
//package com.java2s; import javax.swing.text.JTextComponent; public class Main { public static double getDoubleTextField(double defaultValue, JTextComponent c) { try { return Double.parseDouble(c.getText()); } catch (RuntimeException re) { return defaultValue; } } }