Well after checking your code it's probably because of your class extends JFrame
and you're adding all your elements to this extended frame.
But you also create a JFrame
, this isn't a good practice, 1st of all see The use of multiple JFrames, Good / Bad Practice about using multiple frames.
Now going back into your code, let's see about it, as I said before, you're extending a JFrame
on your class like this (I'll refer to this frame as frame1)
public class SetUp extends JFrame implements ActionListener, Checker {
But you also create a JFrame
here (I'll refer to this frame frame2):
JFrame frame= new JFrame("Set Up");
You are trying to dispose
the frame2, it's actually happening that, but if you want to dispose frame1 (which is the one which has all your elements, i.e. the one you're working with), then on this method, you should change:
public void windowclose() {
frame.dispose();
}
for this one:
public void windowclose() {
this.dispose();
}
Also I don't recommend you to extend from JFrame
class it's better to create objects from it like you did.
But if you do so, then you should change your code as follows:
public mmSetUp() {
frame.setSize(500, 300);
frame.setLayout(new BorderLayout());
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.pack();
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == Submit) {
windowclose();
}
}
public void windowclose() {
frame.dispose();
}
I'm not 100% sure this works or compiles, since I'm not at my PC atm, so I can't create a full example, but at 1st view that's what is happening on your class. In 3 more hours or so, I can post a compilable example.
But please check it