Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Revalidate problems

 
Chris Waguespack
Ranch Hand
Posts: 36
Eclipse IDE Flex Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JPanel inside of a JScrollPane that contains objects when you click the add button and deletes them when you click the delete button. Doing an add updates the screen, but a delete does not. Can anyone figure out what's going on?



 
Campbell Ritchie
Sheriff
Posts: 48635
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A very peculiar piece of programming.

Read your deleteAction method and see what it actually does. Both when there is anything in partsList, and even better when there is nothing in partsList.
 
Chris Waguespack
Ranch Hand
Posts: 36
Eclipse IDE Flex Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe you are talking about the lack of isEmpty() checking. I know it needs to be there, just didn't add it for this simplistic example. Am I missing something else?
 
Campbell Ritchie
Sheriff
Posts: 48635
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chris Waguespack:
Am I missing something else?
Yes, I think you are.
 
Chris Waguespack
Ranch Hand
Posts: 36
Eclipse IDE Flex Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright lets see...

First I remove the last item from the panel..
DOH!!
Ok, I need to remove the component not the index-based component.


Then I check to see if the list has any items left in it.
If it does, I modify the constraints, then remove and re-add the component with the new constraints.
When jScrollPane.revalidate() is called, the screen is not repainted.

Thanks again,
Chris
 
satishkumar janakiraman
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should call repaint() method on JPanel.



 
Chris Waguespack
Ranch Hand
Posts: 36
Eclipse IDE Flex Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, thank you! That works nicely. Even after pouring over a lot of tutorials and javadocs, I still can't find the correct times to use repaint(), validate(), invalidate(), and revalidate()...does anyone know of a good resource that explains this in an easy to understand way?

Thanks a lot,
Chris

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic