• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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: 2699
10
  • 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!