MavenHades
Programmer
I am working on a Java Swing application. I have a JFrame that contains multiple panels. Each of these panels are their own class that extends JPanel. So I have a button on one panel and a text field on another panel. Once the button is clicked, I want to change the text in the text field. What is the best way to update the text field?
If I create a method called "setText(String text)" how would I access it from the button panel? I do not want to pass the button panel to the text field panel's constructor as they have to communicate with other panels as well. This would get cumbersome when you have five panels to pass. However this is the only way I know how to access methods of other classes, but are there any other possible methods of communication? Thanks.
If I create a method called "setText(String text)" how would I access it from the button panel? I do not want to pass the button panel to the text field panel's constructor as they have to communicate with other panels as well. This would get cumbersome when you have five panels to pass. However this is the only way I know how to access methods of other classes, but are there any other possible methods of communication? Thanks.