import javax.swing.*; import java.awt.event.*; class Mas extends JFrame { JButton gomb; Mas() { gomb = new JButton("Nyomj"); gomb.addActionListener(new GombKezelo()); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); add(gomb); setSize(300, 200); } class GombKezelo implements ActionListener { public void actionPerformed(ActionEvent e) { dispose(); } } } class Program extends JFrame { JButton gomb; Program() { gomb = new JButton("Nyomj"); gomb.addActionListener(new GombKezelo()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); add(gomb); setSize(200, 100); setVisible(true); } class GombKezelo implements ActionListener { public void actionPerformed(ActionEvent e) { Mas m = new Mas(); m.setVisible(true); } } public static void main(String args[]) { new Program(); } }