This code segment is called when the JFrame is created, and when it reaches the dispose () line, it does not close. I know that it falls into this block because another JFrame really opens, the only problem is that it does not close. Does anyone know why?
public LogIn(String title) { super(title); checker = new Open(""); deserializeOpen(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(300, 300); getContentPane().setLayout(new BorderLayout()); getContentPane().setBackground(Color.orange); Login = new JButton("Login"); Create = new JButton("New Profile"); Login.addActionListener(this); Create.addActionListener(this); buttons = new JPanel(); buttons.setBackground(Color.orange); buttons.setLayout(new GridLayout(0,2)); buttons.add(Login); buttons.add(Create); Title = new JLabel("Scrambler"); Title.setFont(new Font("Times New Roman", Font.BOLD, 24)); Name = new JTextField(4); name = new JLabel("Name:"); password = new JPasswordField(4); pass = new JLabel("Password:"); Text = new JPanel(); Text.setLayout(new GridLayout(6,0)); Text.setBackground(Color.orange); Text.add(Title); Text.add(name); Text.add(Name); Text.add(pass); Text.add(password); getContentPane().add(Text, BorderLayout.CENTER); getContentPane().add(buttons, BorderLayout.SOUTH); show(); } public void deserializeOpen() { try { FileInputStream door = null; try { door = new FileInputStream("Check.ser"); } catch (FileNotFoundException e) { new Activator(); dispose(); } if(door!=null) { ObjectInputStream reader = new ObjectInputStream(door); checker = (Open) reader.readObject(); } } catch (IOException e){e.printStackTrace();} catch (ClassNotFoundException e){e.printStackTrace();} }
these are just two code segments, the body is the first part, and deserialization is the one that causes the problem.
I am sure the dispose () line has been reached because I just placed System.out.print () directly and below the dispose () object and printed
source share