• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using user interaction  RSS feed

 
Keith Spriggs
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Hi Guys
Can you help,
I'm trying to do is get the user to make a choice and when that choice is made then to do some more code then to return to base menu.
I have cut down the code so that it is button being pressed.
I have done the same action as a command line prompt and it was straight forward.
If you could also point me to where I could find further help if you can't



This is the code that actually does the work
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, your code seems all over the place

frame1.setLayout(new java.awt.GridLayout(2, 1));
...
frame1.getContentPane().add(label1, BorderLayout.CENTER);
so, what's the layout supposed to be?

and this
System.out.println("White Wine " + chablis.getChoice());
will (should) only print out
Wine, women and song

and then
> then to do some more code then to return to base menu.
so what's base menu?

 
Keith Spriggs
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What it is is an assignment over the summer.
What the main idea is that the person has to do is choose between adds, lists and searches for wines.
They will then enter in the details about the wine and then it gets stored into a database.
I have gotten it working perfectly from the command line and now I'm trying to upgrade it to the GUI version.
The Command line returns the person choice to a switch statement which then will bring in the required actions.

I'm using the system.out.println statements as markers to display the checkpoints on the code to let others see the position where I am at, what is working and what is not.
This is for anyone helping me as they can see where the outputs are going wrong.
I came across that code for organising the layout as in the actual program i'll have 7 buttons and 1 label and it will be broken into 2 cols of 4 rows.

I didn't want to put the full code in place as it would waste space in the forums, so I rewrote the code to make it simplier.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
from your description perhaps setting up JMenuItems for your add/list/search options.
you could have different panels for your main/add/list/search components, added to a CardLayout panel.
each menuItem would CardLayout.show(..) it's relative panel.
in the actionListeners to add or select from list/search, the final task would be CardLayout.show(..) the main panel.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!