Hi, I disabled all Swing repaiting and added my own Jpanel with will do all painting with active rendering.

Now I'm trying to place this JPanel inside my JFrame. BUTWhen I set the JPanel as contentPane or add it in the center then a part of the Panel is hiden by the frame decorations. How can I force the Jpanel to display totaly, without a part being hiden.I know one solution: create a top cst make it 10 pixels and everytime i paint add it to the y var. But then again... that isn't a 'real' solution.

I would like to be 0,0 the left top of my Jpanel and not 0,0 hiden behind the decoration...

I know about getInsets(); but I don't know how that solves the problem.

What I do is to set the size of the panel to (widht, height) and the size of the frame to (width + insets.left + insets.right, height + insets.top + insets.bottom). If you want you can do it the otherway round (setting the frame to (width, height) and subtracting the frame-insets from the panel-size). Hope that helps

add(gamePanel, BorderLayout.CENTER); // Ellements automatic resize to fit the Frame.should be replaced by getContentPane().add(gamePanel, BorderLayout.CENTER), indeed the frame contentpane layout is overlapping the contentpane...And as for going to FS mode, a Window instance can always be setUndecorated(true) to clear the look-and-feel decoration if and only if the JFrame has not been made displayable, that is has not been made visible. See : isDisplayable() and setVisible(boolean)

should be replaced by getContentPane().add(gamePanel, BorderLayout.CENTER), indeed the frame contentpane layout is overlapping the contentpane...

Sorry, but I have to disagree:

Quote from: javadoc 1.5 JFrame

As a conveniance add and its variants, remove and setLayout have been overridden to forward to the contentPane as necessary. This means you can write:frame.add(child);And the child will be added to the contentPane

Somewhere (but I really don't remember where) the documentation says that the insets are not known until the frame was one time visible on the screen. So you have to do frame.setVisible(true) before frame.getInsets() works.

ok, that worked the Jframe is now bigger, but the JPanel is still positioned behind the decoration.So I need to tell the Jpanel to move down, and right according to the insets.So I tried to override getInsets in my panel but it is not called by pack at all.

I know, i know i'm a bad boy i paint at init it was just a quick test...

I figured it out! by looking at the spaceinvaders game by Kevin Glass, mayby i should examine those again :d

it seems that when you add a panel to a contentpane it goes straight up behind the decor, but a awt canvas isn't affected by the pack() so it stays in place?,... if somebody could give a better explanationgo ahead.

i know that mixing awt and swing is not good. and i alsoo know that on every tutorial they use a canvas inside a Jframe mayby it's for this reason, i don't know. But i got my 0,0 cordinate where i want it to be.

A Canvas is a heavy weight component, so it will always draw above light weight components. Swing is made of almost entirely light weight components. That is why I always recommend to people to do the ENTIRE Java Tutorial before trying to do your own stuff. All that is explained in there.

I've always just created a JFrame and then added a JPanel to the content pane and never had any issues at all. Unless I explicitly resize the JPanel myself, it always fits the JFrame. Are you trying to resize the JPanel? If that's what you're doing, that's the issue. You should resize the JFrame instead – the JPanel will be resized to fit it, but once again only if you didn't specify a custom size.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org