• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

moving a JWindow

 
Ranch Hand
Posts: 529
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Trailboss
Posts: 23990
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use setLocation() - works like a charm!
 
Barry Andrews
Ranch Hand
Posts: 529
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 [email protected]
 
Barry Andrews
Ranch Hand
Posts: 529
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I will hook the listener up to the JWindow itself. That will be the best way. Thanks!
 
Noah Carroll
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
Attractive, successful people love this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic