I will try to be really specific with my question.So I have an application in a JFrame which contains 3 buttons and each of them open another JFrame and they are doing some animation inside.So what i have to do is close just one frame but not the main frame with it.And in this 3 frames there is SwingWorker who is processing some data,so when I close specific frame I want this application to stop and not doing in a background.
Asked
Active
Viewed 42 times
-1
-
And where is your question? Do you want to know, how to stop a `SwingWorker`? – Sergiy Medvynskyy Aug 03 '17 at 13:19
-
How do I close a frame and stop the application in the second one, without closing the main one? – Jan Aug 03 '17 at 13:23
-
See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/q/9554636/418556) – Andrew Thompson Aug 03 '17 at 22:20
1 Answers
1
You can add an actionListerner on the click of the button..Once the button is clicked you set the visibility of a specific frame to false the user the dispose function on that specific frame and cancel its background activities
like below
cancelbtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame1.setVisible(false);
frame1.dispose();

Bradley Juma
- 131
- 13