Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

writing ActionEvent to jButton  RSS feed

 
sunil ingalagi
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.....
 
Campbell Ritchie
Marshal
Posts: 55698
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Marshal
Posts: 55698
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
� . . and don't ask the same question twice.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apparently Sunil's trying to get lucky, hoping that someone will post the codes
 
Campbell Ritchie
Marshal
Posts: 55698
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Somebody has posted the code, Darryl. Me. Just not here.
 
sunil ingalagi
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it.......
i just made a call to main method of of second frame in actionperformed method........
 
sunil ingalagi
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
now i have another problem ......
 
Campbell Ritchie
Marshal
Posts: 55698
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!