This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

dynamic component invalidate/validate painting issue (image examples included)  RSS feed

 
George McCain
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a panel that is dynamic. The contents are rendered depending on what the user selects in a ComboBox (occurance combo box)
as seen in this image
When I select a different value from the occurance combo box, I generate a remove the old panel, generate the new panel and add it to the component,
then I invalidate and re-validate the component.
When I switch to the next occurance in the combo box, I generate the panel and the output is like this
[/CODE]
however when I switch to the previous occurance in the combo box, It paints the correct panel, however the previous panel is still displayed. as seen below
[/CODE]
I have tried a few combinations of
repaint
paintImmediately
invalidate
validate

[code]
eventTimePanel.remove(eventTimeDetailsPanel);
eventTimeDetailsPanel = new JPanel();
//I then dynamically create the panel with the appropriate input boxes
eventTimePanel.add(eventTimeDetailsPanel, BorderLayout.CENTER);
eventTimePanel.invalidate();
eventTimePanel.validate();
[/code]
Thanks in advance for suggestions/comments/help
 
George McCain
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
images u/l incorrectly
here are the new ones.
1st

2nd

3ed
 
Charles Hasegawa
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by George McCain:


Try this:
 
George McCain
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tried that code.
Now when I switch from the 1st option, to the second option.
The screen flickers (repaint) and what is drawn is screen 3.
Which is not correct at all. (the 1st panel is drawn over the 2nd panel.. resulting in screen #3)
 
Tim Troy
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I find this helps at times.
 
Henrietta Martin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried using a card panel, and just flipping back and forth between the different views?
 
George McCain
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ha just thought of that lastnight.
After looking at the code.. i started thinking and card layout seems to be the answer.
will let you guys know how it goes
thanks in advance
 
George McCain
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Happy to say that Henrietta's suggestion of card layout accomplished the task

Thanks all for helping
 
Henrietta Martin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great!! this scenario is just what Card Panel seems to work best for.
Glad it worked.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!