I am from system programming background in C and Java programming is Greek and Latin for me.
So my problem is:- I have 2 JFrame Objects
- I have a parent Object A
- which has child Objects B.
Object B has buttons on it.
If a button is clicked in B I want to update the UI of parent Object.
How can I can communicate to the parent – to update itself?
Use a modal dialog or
JOptionPaneinstead.Using a modal dialog, whatever code line comes immediately after setting it visible, is blocked from being processed until it is closed. That is where you examine (the return value of the option pane &) the value of the controls you put in the dialog. Note that the idea here is do not extend dialog. Instead just create an instance of one in the main code, create the controls, add them to it, and show it using the main frame as the parent.
Putting ‘everything in one class’ is not a good design, nor what I am suggesting in general. It is just that there is little cause here for the main GUI not to have references to controls that affect/update it.