Hello all,

can anyone tell me how to make a JFrame fixed, by not allowing user to drag it somewhere else in the window? like doking the JFrame in the screen, also disallow user to resize it.

Thanks.

I think there is nothing such as absolute position of frame. However you can disable resizing by using inherited method setResizable of Frame

Could you have a Window listener that uses setLocation to move it back.

this.setUndecorated(true);

you can do it via this..
Enjoy..

@amit.hak50 you better read original question and not to take very first google result that pop-ups on you. Otherwise you wouldn't suggest method that deals with layout instead of positioning...

http://java.sun.com/javase/6/docs/api/java/awt/Frame.html#setUndecorated(boolean)

public void setUndecorated(boolean undecorated)

Disables or enables decorations for this frame. This method can only be called while the frame is not displayable.

@peter
I understand the question ..

do
this.setResizable(false);
this.setUndecorated(false);

you can't able to resize it and can able to move it ..i thin now you got it ...

and well ..i don't use google much ..it finishes your intelligency

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.