开发者

Java: clicking on button->start new frame

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜