Jeremy Weisener
Jeremy Weisener

Reputation: 81

JButton not sending action command

I am working on a school project and I'm having a dickens of a time trying to get the JButton to do..well.. anything! this is my code, I don't know how important the other .java files are.

I started with a simple code that worked but after adding and editing it can't seem to update the text exactly how I want it.

    <removed>

var1, var2, etc. that are being passed in are stored as such..

they are all in another .java file

the Function.fun

    <removed>

Upvotes: 0

Views: 68

Answers (1)

MadProgrammer
MadProgrammer

Reputation: 347204

Okay...

  1. Don't rely on static, it's not going to help you and will create a whole lot of new issues which will be difficult to solve
  2. The main problem is, your code is generating a NumberFormatException - java.lang.NumberFormatException: For input string: "javax.swing.JSpinner[,8,6,109x26,invalid,layout=com.apple.laf.AquaSpinnerUI$SpinnerLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777536,maximumSize=,minimumSize=,preferredSize=]"

So, based on the exception, it's obvious that Double.parseDouble isn't getting the value it excpects

So, having a deeper look at your code...

if (jspValue1.getValue() instanceof Double) {
    s = jspValue1.toString();
    d = Double.parseDouble(s);
    return d;
} else {
    return 0.00;
}

You're passing the result of jspValue.toString to Double.parseDouble, but he fact is, it's just not required.

You've already determined that the value from the JSpinner is a double, so you on;y need to cast it...

double value = 0.00d;
if (jspValue1.getValue() instanceof Double) {
    value = (Double)jspValue1.getValue();
}
return value;

Upvotes: 2

Related Questions