Java window not maximising properly on screen with no taskbar using Substance LAF
I've just noticed that when I maximise a frame on my second screen - which has no taskbar - then it ends up with approximately the bounds one would expect if the taskbar was there.
I've just noticed this having switched to Windows 7. Previously in Vista, I had a utility to add a taskbar to both screens, so this may have been an issue there as well if that were not the case. I'm pretty sure this hasn't been an issue in Linux with a couple of window managers that I've tried...
If I run my program with the default LAF, then the proper behaviour is exhibited (using the full horizontal space of the screen). I suppose StackOverflow isn't really the best place to file a Substance bug report, but if anyone can suggest a remedy, or confirm that it is indeed a bug and help to identify the circumstances under which it occurs it would be much appreciated.
edit: I've just been digging through the source code a bit an开发者_开发知识库d found some references to issue 213; precisely the defect I'm now experiencing, which was supposedly fixed at the time (back in 2007) and reported to be working correctly in XP & Vista with a contemporary build (4.1). I might try to debug the relevant bits of code at some point; looks fairly manageable.
/tumbleweed
I was going to say, if it's only occurring with the Substance LaF, then it definitely sounds like a bug that you should report... but I just saw your edit before posting. Good luck with persuading them to fix it after 4 years!
In the meantime, the only real workaround you could try is getting the insets of the current display and setting the size that way. Here's some code which works out the resolution, bounds and how much usable space is available on each of your monitors:
public static void main(String... args) throws Exception {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gds = ge.getScreenDevices();
for (GraphicsDevice gd : gds) {
GraphicsConfiguration gc = gd.getDefaultConfiguration();
System.out.println("Bounds = " + gc.getBounds());
System.out.println("Insets = " + Toolkit.getDefaultToolkit().getScreenInsets(gc));
}
}
On a dual-screen Windows setup like I have, this shows the following:
Bounds = java.awt.Rectangle[x=0,y=0,width=1280,height=1024] Insets = java.awt.Insets[top=0,left=0,bottom=30,right=0] Bounds = java.awt.Rectangle[x=1280,y=0,width=1280,height=1024] Insets = java.awt.Insets[top=0,left=0,bottom=0,right=0]
Notice the 30-pixel insets at the bottom of monitor 1.
Now all you need to do is work out what screen your application is running on. You can use Window.getGraphicsConfiguration()
this to get the graphics configuration for the active screen if your application window is a JFrame
or any other subclass of Window
.
I hope that helps (and perhaps it will help the people working on the Substance bug!)
精彩评论