wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes moving a JWindow Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "moving a JWindow" Watch "moving a JWindow" New topic
Author

moving a JWindow

Barry Andrews
Ranch Hand

Joined: Sep 05, 2000
Posts: 523

Hi All,
Does anyone know how I can move a JWindow at runtime? I want to use JWindow because I do not want the title bar. Do I need to hook up a listener or what? Also, is there a way to set up some kind of border on a JWindow? Thanks for your help!

Barry
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20494
    ∞

Use setLocation() - works like a charm!


permaculture Wood Burning Stoves 2.0 - 4-DVD set
Barry Andrews
Ranch Hand

Joined: Sep 05, 2000
Posts: 523

No, no, no........ Sorry about the confusion. I meant the user moving the window. Since it has no title bar, a user cannot move it. So, is there a way to fix this?
Thanks,
Barry
Noah Carroll
Ranch Hand

Joined: Sep 20, 2000
Posts: 96
The best way to do it is to implement a mouse motion listener to either the entire window or a component within the window. Then when the user clicks and drags on that part you can have the entire window move to the new location. It is quite simple code. I have done it before, but it is on a different comp. I will post it tonight unless someone else does.
------------------
I hope its helps, feel free to email me noahcarroll@juno.com
Barry Andrews
Ranch Hand

Joined: Sep 05, 2000
Posts: 523

Yes, I will hook the listener up to the JWindow itself. That will be the best way. Thanks!
Noah Carroll
Ranch Hand

Joined: Sep 20, 2000
Posts: 96
Barry, here is the code that I used a while back in one of my applications. It is concise and works great. Just use the handler for your mousemotion.
<PRE>
class MouseMotionHandler extends MouseMotionAdapter {
public void mouseDragged(MouseEvent e) {
window.setLocation(
window.getLocationOnScreen().x - (p.x - e.getX()),
window.getLocationOnScreen().y - (p.y - e.getY()));
}
}
</PRE>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: moving a JWindow
 
Similar Threads
JWindow issue
Displaying a JWindow
JWindow problem....
Why I can't change the JWindow's color?
Swing application without title bar