开发者

Java: clicking on button->start new frame

开发者 https://www.devze.com 2023-01-22 01:00 出处:网络
I am new to Java. I made a开发者_Go百科 new NewJFrame.java. In my current frame, i have a button, how can i link it to NewJFrame.java?Add an event handler to this button and in it you create and sho

I am new to Java.

I made a开发者_Go百科 new NewJFrame.java.

In my current frame, i have a button, how can i link it to NewJFrame.java?


Add an event handler to this button and in it you create and show NewJFrame.

Edited: This is a basic example how to make a JFrame:

//1. Create the frame.
JFrame frame = new JFrame("FrameDemo");

//2. Optional: What happens when the frame closes?
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//3. Create components and put them in the frame.
//...create emptyLabel...
frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);

//4. Size the frame.
frame.pack();

//5. Show it.
frame.setVisible(true);

Please RTFM.

0

精彩评论

暂无评论...
验证码 换一张
取 消