I have been developing command line programs in Java for a while now and am investigating ways to implement a GUI solution. I am new to this so any help would be extremely helpful. Thanks in advance.
I have recently asked another question about buttons but I now have another.
I have been learning from a book how to use the action listener to perform actions based on buttons. However, in the book, the buttons simply called a method which produced a text output.
I need a way to allow the user to press a button which takes him/her to a new window with different buttons/options and if the user wants they can press another button to return to the previous window. If someone could show me a skeleton solution with explanation for my example below:
user is presented with two buttons, “library menu” and “account menu”
if the user presses “library menu” they are taken to a window with options to add book, delete book, etc with a final button to return back to the home screen.
If the user presses “Accounts menu” they are presented with a new window/menu with buttons to add, delete, rename, etc and again a final button to return back to the home screen/main menu.
With the command line this was simple because choosing library would call a method in the library class. That method would have a switch case which called different methods based on the users input and when the user entered ‘e’ for example the switch case had an option to return out of the method i.e. a return statement took the user back to the method that initially called it (in the home screen).
I am extremely grateful for any help/advice/information on this!!!!
It’s generally not recommend to present multiple windows or frames to the user, it becomes quickly confusing and annoying.
Generally, if you want to switch the view you should use a CardLayout, which would allow you to change what’s on the users main display.
You could also use a JTabbedPane which would allow the user to move between different views as they like