Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

1
Change JLabel from another class. Java
Post Body

So, I have a "Main" class, a "Panel" class and a "Day" class. In my Panel class, I have created a JFrame obejct and inside my Panel class I have created a JButton and a JTextField. When the content of the text field is "Monday" I want to display the name of the day and rather I have school on this day. For that, I want to use JLabel. Since the method of displaying the name of the day etc is inside the Day class, I have to create the JLabel object inside the Panel class but edit it inside the Day class.

However, when I use text.setText("Test"); it does not compile. In Eclipse, it gives the following error: text cannot be resolved (text is my JLabel object). I think that the Day class simply doesn't know the text object (even when I make the text object static, which helped in similar cases).

Does anyone know how to fix this Problem? I can provide code, if needed. But making simple enough to post it here would be exhausting. Maybe someone can help me without. If not, I will absolutely happily do so.

Author
Account Strength
80%
Account Age
4 years
Verified Email
Yes
Verified Flair
No
Total Karma
348
Link Karma
311
Comment Karma
37
Profile updated: 4 days ago
Posts updated: 1 month ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 years ago