Jpanel painting problem
I am developing a gui application and i have a frame which includes two panel. One of them includes some buttons and textfields and a combobox and the other panel paints something over itself. I use timer and overrided paintcomponent method but it always draws the other panel's view on this panel also. Clearly i see over my frame two panels both have same look but one of them is drawn the other is not. why my drawing panel gets the other panel's view and draw it.
You've got a bug in your code. Your best bet is to present your code to us in a way that will make it easy for us to analyze it and figure out what's wrong. I recommend that you simplify your code as much as possible so that it is very small but still compilable and runnable on our boxes, and then post it here. This will offer your best chances of getting prompt useful help. For more information on how to create this short program, please check out this site: Short, Self Contained, Correct Example
Best of luck!
Also, when posting code here, please use code tags so that your code will retain its formatting and thus will be readable -- after all, your goal is to get as many people to read your post and understand your code as possible, right?
To do this, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.
Another way to do this is to manually place the tags into your code by placing the tag [code] above your pasted code and the tag [/code] below your pasted code like so:
// your code goes here
// notice how the top and bottom tags are different
I found the solution i override paint method instead of paintcomponent it is okay now .