This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Repaint() does not function unless i modify the size of the frame by mouse......  RSS feed

 
Forman Smith
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to drawing something on the panel when i click the button. But now Repaint() does not function unless i modify the size of the frame by mouse......
how should i do?
 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you add components to a visible GUI you need to invoke the layout manager so the size and location of the component can be determined, otherwise the size is (0, 0) so there is nothing to paint.

The basic code is:



In your case you are adding the component to the content pane of the frame so you can use frame.revalidate().
 
Forman Smith
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:

In your case you are adding the component to the content pane of the frame so you can use frame.revalidate().


I add the

it does work!
Thank you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!