• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

My method doesn't seem to be able to access a field?

 
Dick Hammer
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I edited this post in response to

Ralph Cook wrote:This is pretty much unintelligible.

It took me too long to make out that you have not posted all the code. Your description of what is supposed to happen and what does happen is also a bit obtuse; I could make some guesses about what you mean, but it likely wouldn't help since I can't see the code.

I suggest boiling down what you want to do to a small example -- put the variables in the scope they have to be in the real app, to ensure you can get to them from where you want to, but a couple of labels and buttons and a listener or two should be all you need. And then show us all of it -- where you modify these variables, where you attach the listeners, all of it. Often, in the process of making a small executable example of what you're trying to do, you may even discover the answer yourself.


Sorry about the confusion, I had kept some of the code collapsed for readability, but no need to have two big blocks of code, so here's the new shorter program. I don't understand why the method do_btnJbutton_mousePressed doesn't setText correctly. The variable TheFilePath should get set by the call to RandomNessGenerator(). What am I doing wrong in the code?

 
Ralph Cook
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is pretty much unintelligible.

It took me too long to make out that you have not posted all the code. Your description of what is supposed to happen and what does happen is also a bit obtuse; I could make some guesses about what you mean, but it likely wouldn't help since I can't see the code.

I suggest boiling down what you want to do to a small example -- put the variables in the scope they have to be in the real app, to ensure you can get to them from where you want to, but a couple of labels and buttons and a listener or two should be all you need. And then show us all of it -- where you modify these variables, where you attach the listeners, all of it. Often, in the process of making a small executable example of what you're trying to do, you may even discover the answer yourself.
 
Dick Hammer
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok thanks, check out the new edited code above.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Inside the method RandomNessGenerator you are declaring and initializing a new String variable, which happens to have the same name as the member variable. So, you're not setting the member variable, you're just initializing the new variable inside the method.

Remove the type name (String) in front of the variable name.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dick Hammer wrote:Ok thanks, check out the new edited code above.
No, no, no.

Don’t edit code which has been replied to; that might make the reply look like nonsense.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic