Communication between frames, windows and components in Java Swing -


to

I have the main application window (Jefaram) Click to me JPanel with Jepianel on one of the buttons buttons After I create a JDialog window where the user can choose two options: "do it" or "cancel". After clicking on "do this" the dialog stops and then I make some kind of progress window (another jdyology) with the progress bar. In the progress window I performed the swingworker with long task. On completion of the work, I show a message dialog (joption pane.showdown Diiology) with information about the result of the work dialog ("success" or "unsuccessful"). The result of this work determines the position of the main app window (I change the label on the button, for example "login" / "logout"). How can I "send" results in this swingwalker (method (in method)) in the main app window to refresh the status of the main app window (changing the button's label)? Do I have some type of controller, Or refer to the main app window?

Thank you in advance, seishin

Controller After the object you want to notify the context of the main window below the stack, and then To get such information, add a method to the main window.

For example, JFrame in your main window:

  Public Zero Functional (Boolean Success) { ...} ... JDialog dialog = new JDIOlog (..., this);   

Then save the reference of your main window in the dialog creator, and when the task is completed , Then call mainWindow.taskComplete (true / false) .

Comments