• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Immovable JFrame

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I would like to have a JFrame that is immovable: it appears on the screen where I tell it to and the user can press on the JFrame and try to drag/move the JFrame but the JFrame does not move.
I have succeeded in doing this by adding a ComponentListener to the JFrame and calling setLocation(originalX, originalY) in ComponentListener's componentMoved() method. This works but is jerky - you can see the JFrame moving and moving back.
Is there a way to do this without the jerkiness?
Thanks for you help.

The driver class


class ImmovableJFrame


The GUI panel class - does nothing right now
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use an undecorated JFrame or a JWindow and there isn't a title bar for the user to drag around.

That said, I'm glad I don't have to use your application. I like to be able to move things to where I want them.
 
Rosie Fairfield
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Darryl,
Thank you for your answer. I looked at undecorating the frame but that does not give me what I'm looking for. I am attempting to emulate, in a very small way, the World of Warcraft GUI and functionality. The main panel/screen that holds the action bars and the game field for WoW does indeed have an undecorated frame. However, if you open the Spellbook, the Spellbook does have a frame of some kind and it is immovable. (I don't know why Blizzard wants it immovable but all of the "dialogs' you can bring up in WoW are immovable. I agree that usually I'd let the user move the windows wherever they wanted to.)
I am beginning to think that the Spellbook actually has an undecorated frame and that Blizzard has added some elements at the top to make what looks like a frame's titlebar and a close button. I may need to do that. Does that make sense to you? Any other ideas on making an immovable frame?
Actually, I'm trying a JWindow and I think that's working - I'll add a titlebar and close button and see what I get; still interested in any other ideas you might have.
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also have a JFrame with setLookAndFeelDecorated(true), traverse the hierarchy to get a reference to its title bar and remove the MouseListener(s).
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Darryl. This is bad usability. However, if your requirement insists on the same, I would go for JWindow
 
Rosie Fairfield
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Darryl,
Thank you again for your reply.

However, JFrame has no setLookAndFeelDecorated(boolean); I tried frame.setDefaultLookAndFeelDecorated(true); There is no visible difference in the frame between when I don't call setDefaultLookAndFeelDecorated(boolean);, when I call setDefaultLookAndFeelDecorated(false);, and when I call setDefaultLookAndFeelDecorated(true);.

When I look at my JFrame variable, it has one component, JRootPane; that one component has 2 components, JPanel, and JLayeredPane; the JPanel has no components and the JLayeredPane has one component, a JPanel, which has no components, and none of the components have any listeners to remove.

So, I need more help if you think there is some way for me to do this.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic