Drawing game in a Frame

Hi, I’ve got a problem that I’m really not sure how to remedy.

I’m converting my fullscreen arcade game over to windowed version, actively rendered in a AWT Frame.

The problem is that the origin of the frame is under the top bar of the windows created, so everything drawn at the top and left-most edges of the graphics context isnt shown.

Is there a way around this?

Sorry nevermind I got it. I’m new to using AWT/Swing. I decided to go with a JFrame instead. I just made a Canvas, added to the JFrame’s content pane, drew to it, and it was placed below the title bar.

You should use JPanel instead of Canvas. Since Canvas is awt and JFrame is swing. Swing and awt do not play well together and you may experience problems that you cannot track down the cause for.

Well, if I use a JPanel then I can’t get to the BufferStrategy stuff right. I need it for active rendering. Thats what it seems like from the API and of course the errors I get from compilation. I could just switch my JFrame to a Frame. The only reason I used a JFrame was for the EXIT_ON_CLOSE. I could easily just add a my own WindowListener to the Frame for that effect :).

JFrame inherits Window.getBufferedStrategy()
JPanel inherits JComponent.setDoubleBuffered()

What are you trying to achieve with the buffer strategy?

Just double buffering for 2d sprites and animation. Will the JComponent.setDoubleBuffered() work just the same? I’ll try it out :smiley: