954,554 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Fixed JFrame

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.

RicardoE
Junior Poster in Training
73 posts since Jan 2010
Reputation Points: 21
Solved Threads: 7
 

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

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

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

NormR1
Posting Expert
Moderator
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
 

this.setUndecorated(true);

you can do it via this..
Enjoy..

amit.hak50
Junior Poster in Training
65 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

@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_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

@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

amit.hak50
Junior Poster in Training
65 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: