Forums Register Login

open new window

+Pie Number of slices to send: Send
hi i'm new with java and swing and have the following prob
i build a gui with a few buttons. now i want to pop up a new window if i press a button.
i search for sample codes or similiar.
thnx in advance
+Pie Number of slices to send: Send
Welcome to JAVAWORLD.
For your button, for ex.
JButton myButton = new JButton("Open new window");
JFrame newFrame = new JFrame("New Window");
//add this line of code
myButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// open a new frame i.e window
newFrame.pack();
newFrame.setVisible(true);
}
});
Hope that would help.
Don't count your weasels before they've popped. And now for a mulberry bush related tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 30111 times.
Similar Threads
Servlet session
open new browser window on click of button.
java script for open jsp file
Stand alone window in jsp
new windows
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 15:54:10.