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.
精彩评论