I have question for you: how to open new windows in JFrame using JMenu items and close the previous at the same time. Please do not send me to JFrame documentation because it will not help me, better show me e.g code if you may. What I have now? I make a new functions in my application to call them and that way open new window. Code look like this :
Here I add Listener for a JMenu item. What should be clear for you.
JMenuItem wyswietlbaza = new JMenuItem("Wyswietl baze");
akcja.add(wyswietlbaza);
wyswietlbaza.addActionListener(this);
// Here I call a method to open the window and close another.
public void actionPerformed(ActionEvent e){
new BazaDanych().setVisible(true);
this.dispose();
}
This way work only if i have one window(some main and another e.g window2). When I have 3 windows my code stop work properly even when I make another function like below:
public void actionPerformed1(ActionEvent e){
new ZmienBaza().setVisible(true);
this.dispose();
}
My question : how to add another windows and Listeners for them? I just want to make few windows which should be open by JMenu item and close at the same time(first close second open)but now my Listener open only second window even when I push JMenu item "Open window1". Do you have any ideas?