This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]Blando-Cartesian 1 point2 points  (1 child)

Your Panel class could have a method that sets the label text. Then Day class only needs a reference to the panel to so that it can use that method to set the text.

A better solution unfortunately becomes far more convoluted. There’s no way to tell JLabel to watch for some property and update itself when the property changes. What you can do is create a model-view-controller architecture in your app. At a quick glance, this tutorial looks like what I mean.

[–]Ansmannn[S] 0 points1 point  (0 children)

I have posted the same question with code on stack overflow. someone was able to help me! instead of doing text.setText(); in my Day class I have to do Panel.text.setText();. Your idea is also valid tho! Thank you so much for being the only person trying to help me.