I have already looked at many other similar questions, but no one has answered to my needs. I need to actually x out of the window itself once an action listener within has been used to open the next window. Below is a portion of my code. the reference to "GUITUI" is a similar section of code in another class. I need to actually exit the window once GUITUI has been called, not just use Frame.dispose() or a similar function to clear the contents of the window.
JPanel Race = new JPanel(new GridLayout(5,6,20,15));
getContentPane().add(Race);
setTitle("Choose a Race.");
setSize(500,200);
setResizable(false);
JButton Race1 = new JButton("Human");
Race.add(Race1);
Race1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
try {
GUITUI a = new GUITUI(1);
a.setVisible(true);
} catch (IOException e) {
e.printStackTrace();
}
}});