• Post Reply Bookmark Topic Watch Topic
  • New Topic

GUI almost there. Please help!

 
Dave Johnson
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am experimenting with my code, learning quite a bit about Layout managers, one way or another.
I have a BorderLayout for my main manager. This puts a JToolBar in the north zone. A Gridlayout JPanel in the west zone. A GridLayout JPanel in the center zone. A GridBagLayout JPanel in the east zone. A FlowLayout JPanel in the south zone.
When the program compiles and runs, it looks fine, room for improvement but okay for now. The problem is that there is a cancel JButton on the JPanel in the east zone. When this is pressed it resets the program to the state it started in.
The program does this, with one minor problem. When the program resets the JPanel in the south zone now sits lower than it did originally. Once one of the buttons in the JPanel in the west zone is pressed it aligns correctly again. It's just for the first stage of reinitialization of the application.
To be honest, I would imagine it would be easier for you to just run the code & see the error for yourself.
There are 5 classes, however I am quite sure it is the first class BarTill that needs altering.
BarTill

ChoicePanel

SubChoicesPanel

TillPanel

Details

I would be extremely grateful if some could run this and tell me why I have got this problem.
Many thanks, Dave.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just reading your description, without looking at the code:
Whenever you change the size, number, or identity of components that are already visible on the screen, you must call validate() on the affected container to tell the layout manager to fix things up. Most likely you're failing to do this. You'd want to call this in the button event handler.
 
Dave Johnson
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou Ernest, I had not heard of that method() before.
I'll have to read up on it.
Thanks for sorting this out. As to be honest I have sorted lots of the problems on my own, but that one had me stumped.
I love this place.
Thanks again, Dave.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!