Java Swing open another frame while jbutton being clicked

www.‮ruttual‬i.com
Java Swing open another frame while jbutton being clicked

WindowOne.java

/**
 * @author Lautturi.com
 *
 */
package swing_lautturi;

import javax.swing.JButton;
import javax.swing.JFrame;

public class WindowOne extends JFrame {
	public WindowOne() {
		initialize();
	}
	public void initialize() {
		setTitle("Window 1");
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setSize(500, 300);
		setLocationRelativeTo(null);
		setResizable(false);
		setVisible(true);

	}
}

Main.java

JButton button1 = new JButton("button1");
frame.add(button1,BorderLayout.EAST);

button1.addActionListener(new ActionListener() 
{
    public void actionPerformed(ActionEvent e) {
        new WindowOne().setVisible(true);
    }
});
Created Time:2017-10-02 17:07:13  Author:lautturi