• Post Reply Bookmark Topic Watch Topic
  • New Topic

Immovable JFrame

 
Rosie Fairfield
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • 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
 
Darryl Burke
Bartender
Posts: 5155
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • 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
  • 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: 5155
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • 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).
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!