java - Should I extend JPanel for custom class rendering in Swing? -


i have custom class representing spaceships rotate , fly around on screen. however, realized if want use swing, have render ships via paintcomponent().

this method going use rendering:

    public void render(graphics g){          affinetransform original = ((graphics2d) g).gettransform();         graphics2d g2d = (graphics2d) g;          g2d.rotate(orientation, getgameposition().x, getgameposition().y);         g2d.drawimage(spritedefault, position.x, position.y, null);         g2d.settransform(original);     } 

so in order use swing, should extend jpanel can override paintcomponent , put code inside method, or should jcomponent, or other way?

i want make sure i'm on right track here...


Comments

Popular posts from this blog

Python Kivy ListView: How to delete selected ListItemButton? -

asp.net mvc 4 - A specified Include path is not valid. The EntityType '' does not declare a navigation property with the name '' -