This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not refreshing...

 
Chris Stewart
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm basically trying to move cards left or right based on their starting location. I have some logic which selects two cards (JLabels) and passes them to this method. After each movement (setBounds()), I try and refresh to show their current position but it doesn't happen. Any ideas?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two suggestions... call validate() on the component that holds the card JLabels. And make sure that you are using setLayout( null ) on the parent component, otherwise setBounds() won't work.
 
Chris Stewart
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I set the layout method to null, nothing shows up in my JFrame. I'm using setBounds all over the place in this and it works, I just can't get it to refresh after each loop.
I tried calling the validate method, but that didn't work either.
Here is my entire Layout class: (the moveCards method is at the very bottom)

[ July 05, 2003: Message edited by: Chris Stewart ]
 
Chris Stewart
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fixed this problem, I just needed to put the movement into a thread of its own.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic