Forums Register Login

writing ActionEvent to jButton

+Pie Number of slices to send: Send
hi..
I have two Frames-> FrameA and FrameB and i have a jButton in FrameA on clicking this button i want FrameB to open please help me how do i write ActionPerformed event for this button.. please send some codes if you have...
Thanks in advance.....
+Pie Number of slices to send: Send
You would use the standard technique for adding an ActionListener to the button, and in the actionPerformed method you would put code (or if it's long, a method call) which opens the other Frame.
+Pie Number of slices to send: Send
� . . and don't ask the same question twice.
+Pie Number of slices to send: Send
Apparently Sunil's trying to get lucky, hoping that someone will post the codes
+Pie Number of slices to send: Send
Somebody has posted the code, Darryl. Me. Just not here.
+Pie Number of slices to send: Send
I got it.......
i just made a call to main method of of second frame in actionperformed method........
+Pie Number of slices to send: Send
now i have another problem ......
+Pie Number of slices to send: Send
 

Originally posted by sunil ingalagi:
I got it.......
i just made a call to main method of of second frame in actionperformed method........
now i have another problem ......

I'm not surprised.

If you haven't already created the other JFrame, you should call its constructor from the actionPerformed method. If you have already created it, whihc is probably a better approach, you simply call the setVisible() method from actionPerformed.
Who knew that furniture could be so violent? Put this tiny ad out there to see what happens:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1147 times.
Similar Threads
JFrame focus
How to pop up a JFrame on top of another JFrame ?
Drag and Drop ....and move again ?
Accessing elements of frame A from frame B
Transfer value between JFrame
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 22:43:31.