Is it possible to move an Icon?
In Java, is it p开发者_C百科ossible to use paintIcon to put an icon into a canvas, and then move that icon around using keyboard events like you would a game character?
Once you paint something on the canvas, it stays there, and what was there beneath that location is lost. To "move" the icon, you need to repaint the canvas (or at least what was originally at the location of the icon) and draw the icon at its new position.
This would work better with an applet by registering keylisteners. and overridding the paint method
精彩评论