我在使用Java 1.7的应用程序中使用Synthetica Black Eye LAF(http://www.jyloo.com/synthetica/)。看起来,当我启用了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);
}}