Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Switch  RSS feed

 
Anne Saizan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Can I have switch in GUI?
For example, When I click Student Admin. it will do the Student Admin tasks(add,enrol and payment).

Here is my code.
But i do not know how to do when I click I will open to another window.
Thanks






 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You posted your code in the "quote" tags, so you understand the mechanics of tagging. Next time use the Code tags rather than the Quote tags.

As for your question, I think you're asking how to determine which action to do based on the button clicked and/or the parameters chosen when the button is clicked. There are many possible approaches. One is to add an ActionListener directly to the button in an anonymous inner class and to perform the desired action in response. Another is to leave the design as you have it (not the preferred method, by the way) with all possible actions handled by one actionPerformed() method and determine the source of the ActionListener by using the available methods.

You might find this tutorial a good starting point. There are also good examples of anonymous inner classes for event handling available on the web. I refer to these notes often when I forget something relatively simple or want to explore something new. You can navigate to the home page of these notes and download the whole package for local use wherever you are, or just bookmark them and use them from the web.

Come back for more help when you're ready.
 
Anne Saizan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ooppss sori for that...
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!