• Post Reply Bookmark Topic Watch Topic
  • New Topic

JLabel is in main, can I setText from a subclass?

 
Dustin Yonak
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's my main class:


Withing the TestDraw class I'm trying to set the text of the status JLabel but it can't find it. It's in main because I want to add it to the application JFrame using BorderLayout.SOUTH, which I can't seem to get to work properly if I try to add the JLabel within the DrawPanel class.
 
Frank Hale
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I substituted your DrawPanel for a JPanel then used the JPanel add method to add the JLabel. Seems to work. Not sure if this is what you are intending to do though.
 
Dustin Yonak
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Frank, that works if you only want to update the status JLabel from TestDraw but I'm trying to update in from the DrawPanel class, which I need to use. The error I get is "cannot find symbol variable status".
 
Dustin Yonak
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it, I just moved all of the following:

into the DrawPanel class.
 
Frank Hale
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dustin Yonak:
Got it, I just moved all of the following into the DrawPanel class.


I was getting ready to say if this was a subclass you created you could extend it to do the required functionality. Glad it's working for ya.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to a more appropriate forum.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!