Studyon Minte9.com
Java SE




Open new frame




package testexample; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; public class Test extends JFrame { static JFrame frame2 = new JFrame(); public static void main(String[] args) { Test frame = new Test(); frame.setBounds(200, 200, 400, 300); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setVisible(true); frame2.setBounds(350, 350, 300, 200); frame2.setDefaultCloseOperation(EXIT_ON_CLOSE); frame2.setVisible(false); } public Test() { JPanel panel = new JPanel(); JButton button = new JButton("Open"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { frame2.setVisible(true); } }); panel.add(button); add(panel); } }