Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the Swing UI toolkit in Java, and I want to use the Graphics class to draw images and grids in a control. Which is the most appropriate control for this?

share|improve this question

A cursory bit of searching with Google suggests that you probably want to use JPanel for this, although it's possible you could make use of any control since it looks like the technique you'll want to use is to subclass the control and override a method (the paintComponent method, specifically), which will give you a Graphics instance you can use for rendering.

JPanel appears to be a very basic empty control and so is probably the ideal choice for this.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.