我正在使用Synthetica Black Eye LAF(http://www.jyloo.com/synthetica/)和使用Java 1.7的应用程序。似乎当我启用Synthetica LAF时,如果我将屏幕拖到更大的第二个显示器上,并且通过双击或单击最大化图标来最大化窗口,窗口占用的空间大小与主监视器上的“全屏”大小。当我没有启用LAF时,它不会这样做。就好像它没有意识到它所在的屏幕的尺寸。有没有解决方法呢?
我有效地做到了这一点: Java Toolkit Getting Second screen size 和 java & fullscreen over multiple monitors 这很好,因为现在我可以将首选大小设置为较大显示器的大小,但这对我的最大化问题没有帮助。
这是我的代码:
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);
}
}
答案 0 :(得分:1)
来自客户支持的电子邮件:
这主要是多屏幕环境中已知的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)另一种解决方法是将系统属性“synthetica.frame.fullscreen”设置为true,但这将涵盖操作系统的任务栏。