Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

passing value  RSS feed

 
Rich Wilson
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I have the code right but am not sure? I am trying to pass a value from a text field if the 1st string value is selected in a combo box (not 0 but 1)it works well from the menue but if I set it up and run the app the text field values are not passed. I have tried putting the commands in a new method but still the samething.

Any sugestions from the pros?
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Rich"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Mark
 
Jacquie Barker
author
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure that there are no NumberFormatExceptions being thrown when you read from the text fields? Try wrapping your code in a try - catch block:

try {

your code
}
catch (NumberFormatException e) {
System.out.println(e.getMessage());
}
 
Marilyn de Queiroz
Sheriff
Posts: 9080
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if they choose index 0 (the first string)?

Also, I notice that you have aprnum and yearnum if index == 1 and apr and years if index > 1. Is that intentional?
 
Rich Wilson
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The 0 string is null just so the box is blank when the app starts.
 
Rich Wilson
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured it out by looking at it from several different angels.
 
Marilyn de Queiroz
Sheriff
Posts: 9080
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And the problem was ...?
 
Rich Wilson
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was putting the code in the wrong place in the code. I was trying to put the if statement in the listener instead of calculate() once I moved it the app worked like a charm.

I would like to say thank you for the help.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!