How to reference the conents of a variable instead of a variable in Java
<p>Ok, I'm trying to make a quick double validator for any JTextField in a program. I would like to pass this to a function which then checks the contents of a field, makes sure it's a double, then return it as a double to the function. </p>

<p>Here is what I have so far but theTF.getValue() should get the value of the string, not the string itself. </p>

<pre><code>    public double valDouble(String theTF)
    {
            double theDouble;
            try
            {
                theDouble = theTF.getValue();
                return theDouble;
            }
    }
</code></pre>

<p>How can I run the getValue() on the contents of the string?</p>

<p>Edit:
Ok, I somewhat screwed up my meaning. I understand the parseDouble, but I left it out on accident here is what I have now:</p>

<pre><code>    public static double valDouble(String theTF)
    {
        double theDouble;
        try
        {
            theDouble = Double.parseDouble(theTF);
        }
        catch(NumberFormatException e3)
        {
            theDouble = 0;
        }
        return theDouble;

    }
</code></pre>

<p>My Real issue is theTF represents the name of a TextField. I need the value OF the text field not the value in theTF. I'd like to have this here to, perhaps, highlight the field red etc. </p>

<p><strong>Answer</strong>(Thanks Hunter):
The best way was to pass the Object, not sure why I was trying to parse out the value of a string reference. </p>

<pre><code>    public static double vDbl(JTextField theTF)
    {
        double theDouble;
        try
        {
            theDouble = Double.parseDouble(theTF.getText());
        }
        catch(NumberFormatException e3)
        {
            theTF.setText("Invalid");
            return 0;
        }
        return theDouble;
    }
</code></pre>
