*
The moose likes Swing / AWT / SWT and the fly likes repaint method and graphics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "repaint method and graphics" Watch "repaint method and graphics" New topic
Author

repaint method and graphics

Mark Lockery
Greenhorn

Joined: Jun 04, 2004
Posts: 19
I think this may be a stupid question, but i made an applet where an image moves around as you move the mouse, and when you click in the same area as another (stationary) image, the stationary image changes. I managed to get the moving image to stop refreshing so fast by, well im not sure. But anyway, when i put one image over another, it always displays the stationary image over the moving one. Is there a way to tell it which image to display over the other?
Darin Niard
Ranch Hand

Joined: Jun 08, 2004
Posts: 118
Draw the background before the object, then repaint?
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

I'm moving this to the Swing/AWT forum, where it's more on-topic.


[Jess in Action][AskingGoodQuestions]
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
You may be able to exploit JLayeredPane for this. During initializaiton you'd do this:

panel.getRootPane().getLayeredPane().add(floatingComponent, JLayeredPane.PALETTE_LAYER);

And then to move stuff around, you'd do something similar to this:

onMouseMoved(MouseEvent e) {
// Move it to the mouse
Point location = SwingUtilities.convertPoint(e.getSource(), e.getPoint(), panel.getRootPane().getLayeredPane());
floatingComponent.setLocation(location)
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: repaint method and graphics