java界面设计监视器_Java - 使用Synthetica外观和感觉(LAF)和多个监视器最大化窗口...

我在使用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);

}}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值