• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

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

 
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.
 
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.
 
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!