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?
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().