如何用java以编程方式更改显示设置?

时间:2011-03-09 07:52:42

标签: java configuration windows-xp settings

是否可以使用Java编程语言在Windows XP中更改(更改/更新)显示设置(配置)?

我想做这样的事情:

Display[] displays = WindowsXPSystem.getDisplays(); //get all available displays (monitors). assume there are currently two monitors connected 
Display d0 = displays[0]; // the first is 24" and is positioned on the left
d0.setPrimary(true); // and it should be primary, so all new windows open on it.
d0.setSize(new Dimension(1920,1080)); //update screen size (resolution)
d0.setPossition(0,0); //and position it on the left

Display d1 = displays[1]; //second monitor is also present
d1.setSize(new Dimension(1440,768)); // and it's 14.1" laptop's display
d1.setPossition(1920,332); //it's positioned on the right

任何想法/建议/ API如何使用Java更新显示设置?

2 个答案:

答案 0 :(得分:0)

我认为使用普通Java是不可能的。在这里看看这个问题:

Detect and Change display resolution permanently using java

如上所述,可能可以通过JNI(Java Native Interface)使用任何本机库,这种包装可以包含本机库。但是,你将失去平台独立性。

答案 1 :(得分:0)

您的问题没有简单的Java解决方案。该函数是特定于通用实现的方法。

但是,如果你真的需要实现这个,你可以使用一个JNI库,它包含调整屏幕分辨率的Windows功能。