问题
every time when I call pack() method on JFrame, it moves to the initial position where was when started. When I try to get the location of the JFrame (getLocation, getLocationOnScreen) it's still the same as initial position no matter I'm moving the window. I am running Archlinux with Awesome WM. Please help.
Thanks Uiii
EDIT: What I just want is to be able to show or hide some components in the main window (which cause layout resizing) without moving the windows to the initial position.
EDIT2: So I just found that Paŭlo (from comment) is right. It works fine in Xfce, but in Awesome WM not.
EDIT3: I really don't understand why are you voting the question down. It's the first time I'm using pack() function, so I don't know what is its correct behavior. There is no explanation in the java API document if the window's position will change. I just use this the first in Awesome WM which I am using as my window manager, so I don't know that should behave another way. I have tried to find something about it on the internet but found nothing. I think that this question can be useful to someone after I've found the solution. There are certainly another java developers who are using Awesome WM (or some similar with the same problem).
回答1:
I've found solution! The problem is that java has some problems with some window managers. Solution is simple - just install wmname utility ( http://tools.suckless.org/wmname ) and run 'wmname LG3D
'. It changes actual window manager's name to LG3D and java consider it as compatible WM.
I know this before my problem. So I am trying to set the LG3D name globally in .xinitrc file but it looks like not working. I have to call 'wmname LG3D
' explicitely in every terminal which will run some java apps.
来源:https://stackoverflow.com/questions/6084977/jframes-position-and-pack-in-awesome-wm