StartupWindow.java
import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.Jframe;import javax.swing.SwingUtilities;public class StartupWindow extends Jframe implements ActionListener{ private JButton btn; public StartupWindow() { super("Simple GUI"); setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE); btn = new JButton("Open the other Jframe!"); btn.addActionListener(this); btn.setActionCommand("Open"); add(btn); pack(); } @Override public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if(cmd.equals("Open")) { dispose(); new AnotherJframe(); } } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable(){ @Override public void run() { new StartupWindow().setVisible(true); } }); }}AnotherJframe.java
import javax.swing.Jframe;import javax.swing.JLabel;public class AnotherJframe extends Jframe{ public AnotherJframe() { super("Another GUI"); setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE); add(new JLabel("Empty Jframe")); pack(); setVisible(true); }}


