• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can JLabels print string from an array list  RSS feed

 
Ranch Hand
Posts: 36
Chrome Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok so I have an array of string that collects various strings inputted by the user. I need to have those strings go to a JLabel. Problem is, my code won't compile because "<array> cannot be resolved to a variable"

Here's an idea of what I'm doing.



player1 is declared in the field as

 
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
private JLabel player1;

That's not an array. It should be

 
Jacob Coddaire
Ranch Hand
Posts: 36
Chrome Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe I wasn't clear....

I'm pulling the bits from my code that matter regarding this issue....


I keep getting the following compiling error:

playerArray cannot be resolved to a variable.

Any ideas?
project-1.jpg
[Thumbnail for project-1.jpg]
 
Greenhorn
Posts: 13
Firefox Browser Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I believe that this problem lies on variable scoping. In other words, the second method can't "see" playArray. Unfortunately I can't tell where exactly is the problem, because the sample from your code don't show it.

Try to find where playArray "vanishes", make it "visible"(change scope) and I believe that your problem is solved.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!