Do you know how can I close JFrame window while I am opening another?
I know how it works on buttons but now I want do the same for menu items.
Here is my code :
    public static void main(String[] args) {
    JFrame frame = new JFrame("Test");
    frame.setVisible(true);
    frame.setSize(200, 200);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    JLabel label = new JLabel("Hello");
    JPanel panel = new JPanel();
    frame.add(panel);
    panel.add(label);
    JMenuBar menu = new JMenuBar();
    frame.setJMenuBar(menu);
    JMenu action = new JMenu("Action");
    menu.add(action);
    JMenuItem Info = new JMenuItem("Info");
    action.add(Info);
}
 
     
    