• Post Reply Bookmark Topic Watch Topic
  • New Topic

repaint entire component  RSS feed

 
Jerry Olsson
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!
I'm having some problems with paintings. I have a painting area which extends JPanel. On this area I add different objects that also extends JPanel. I have overridden the paintComponent in both classes and so far everything is working fine. I can move around the added object without problems.
When I try to write a line from (0,0) to the added object while I move it around it wont repaint the entire painting area. It only repaints the rectangles where the object was moved from and to. How can I force the painting area to repaint the entire area instead of just the one's that changed?
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually in painting we use a single JPanel for all the drawing. You can draw images and graphic primatives (Rectangle, Polygon, Ellipse2D, Line2D, GeneralPath, etc) and move them around with swing timer or mouse event code. Adding components to the drawing area will obscure the graphics area since they must occupy some of the space. If I missed the point please feel free to say/ask more or demonstrate with code.
[ May 18, 2005: Message edited by: Craig Wood ]
 
Jerry Olsson
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Every one of the "boxes" we move around holds quite a bit of data and also works as droptargets. There are lines between the boxes that would have to be redrawn whenever a box is moved and when in motion.
We found out today that it actually didn't have to be movable. When we want to drag a box to another (to a droptarget) we can just change the mouse pointer to indicate a drag being executed. But I still can't stop thinking of the painting...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!