我正在使用Synthetica Black Eye LAF (http://www.jyloo.com/synthetica/)和一个使用Java 1.7的应用程序。似乎当我启用Synthetica LAF时,如果我将屏幕拖到第二个较大的监视器上,并且我通过双击或单击最大化图标来最大化窗口,窗口占用与主监视器上的"全屏"大小相同的空间量。当我没有启用LAF时,它不会这样做。它似乎没有意识到它在哪个屏幕上的尺寸。有什么解决办法吗?
我已经有效地做到了:Java Toolkit获取第二屏幕大小和java和;全屏多显示器这很好,因为现在我可以将首选大小设置为较大的显示器的大小,但这并不能帮助我解决最大化问题。
下面是我的代码:package mil.innovation.bewear.maintenance.windows;
import de.javasoft.plaf.synthetica.SyntheticaBlackEyeLookAndFeel;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
public class Windows {
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(new SyntheticaBlackEyeLookAndFeel());
} catch (Exception e) {
System.out.println("Look and feel not started");
}
Dimension dimension;
GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] devices = graphicsEnvironment.getScreenDevices();
GraphicsDevice biggest;
if (devices.length > 1) {
biggest = devices[0];
for (GraphicsDevice device : devices) {
if (device.getDefaultConfiguration().getBounds().getSize().getWidth() > biggest.getDefaultConfiguration().getBounds().getSize().getWidth())
biggest = device;
}
dimension = biggest.getDefaultConfiguration().getBounds().getSize();
} else if (devices.length == 1)
dimension = devices[0].getDefaultConfiguration().getBounds().getSize();
else {
throw new RuntimeException("No Screens detected");
}
String filePath = "C:\Users\Bewear2\IdeaProjects\bewear_windows\imgNotFound.png";
JFrame frame = new JFrame("Example");
JLabel lblPicture = new JLabel();
lblPicture.setPreferredSize(dimension);
lblPicture.setSize(dimension);
BufferedImage image;
try {
image = ImageIO.read(new File("imgNotFound.png"));
lblPicture.setIcon(new ImageIcon(image));
}catch (IOException ex) {
System.out.println("Error loading the picture that is supposed to load when loading a picture fails" + ex);
}
try {
image = ImageIO.read(new File(filePath));
Image bufferedImg = image.getScaledInstance(lblPicture.getWidth(), lblPicture.getHeight(), Image.SCALE_SMOOTH);
lblPicture.setIcon(new ImageIcon(bufferedImg));
} catch (IOException ex) {
System.out.println("Error loading picture " + ex);
}
frame.setContentPane(lblPicture);
frame.pack();
frame.setVisible(true);
}
}
客户支持的邮件:
这主要是在多屏幕环境中已知的Java Swing问题,只有在使用不同的屏幕分辨率时才会发生-参见http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6829250。它的目标是在V9中修复。但是,还有另一个问题(#7010721 http://bugs.java.com/bugdatabase/view_bug.do?bug_id=7010721)会影响窗口大小,因此请确保使用最新的JVM。如果这个问题仍然存在,一个可能的解决方案是启用本地框架装饰(参见常见问题解答窗口装饰#1 http://www.jyloo.com/synthetica/faq/#windowDecoration-1),另一个解决方案是将系统属性"synthetic .frame.fullscreen"设置为true,但这将覆盖操作系统的任务栏。