| Author |
How to stop dragging the JFrame
|
R.Joe
Ranch Hand
Joined: Jun 16, 2004
Posts: 31
|
|
|
Hello,I want my JFrame is not moved or draged from the location where i opened the JFrame,it become not movable
|
 |
Nathan Pruett
Bartender
Joined: Oct 18, 2000
Posts: 4121
|
|
|
You can use a JWindow instead of a JFrame... there is no title bar, so the user won't be able to move it.
|
-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
|
 |
R.Joe
Ranch Hand
Joined: Jun 16, 2004
Posts: 31
|
|
Originally posted by Nathan Pruett: You can use a JWindow instead of a JFrame... there is no title bar, so the user won't be able to move it.
Thanks Sir, 4 replying me, but your solution is not sufficient, i want a window having title bar that why i choose jframe, in that window i don't frame is not resizable not closeable throght close button and not movable for that i use this setResizable(false); setUndecorated(true); getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG); this works good but when i try to drag or move this window it shakes that i don't want. could u help me out of this. [ June 19, 2004: Message edited by: Ravi Lekhwani ] [ June 19, 2004: Message edited by: Ravi Lekhwani ] [ June 19, 2004: Message edited by: Ravi Lekhwani ]
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
JFrame's are meant to be moved. That's what the title bar, in part, is for. If you don't want it to be dragged there is a few things you can do. None of which you are going to be satisfied with but I will tell you anway. Do what Nathan said and create your own psuedo title bar using a custom JPa nel. Use a window listener to determine when the frame is being dragged and apply a setBounds or setLocation giving it the inital X and Y values so it pops back into place Maximize your app on the screen so the user can't drag it.
|
 |
 |
|
|
subject: How to stop dragging the JFrame
|
|
|