开发者

Is it possible to move an Icon?

开发者 https://www.devze.com 2023-01-30 14:56 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消