我的怪異監視器的原始分辨率無法被Windows識別,因此我必須爲其設置自定義分辨率。問題在於java不能識別它,因爲它不在Win7的「已批准」列表中,所以全屏模式會「卡住」。 Netbeans從全屏精細出來,所以必須有解決方法。任何人都知道嗎?自定義監視器未被Java識別的分辨率
//編輯(3/29/2010):它看起來像NetBeans是僞造全屏,而不是實際進入全屏獨佔模式,所以這可能實際上不可解決。現在,我也在僞裝它。但似乎java應該認識到有效的 DisplayMode是有效的。
這個例子重現問題:
package resolutionexample;
import java.awt.Dimension;
import java.awt.DisplayMode;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
public class Main {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable(){
public void run() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
DisplayMode currentDM = gd.getDisplayMode();
boolean currentInAvailable = false;
System.out.println("Available resolutions:");
for (DisplayMode availDM : gd.getDisplayModes()){
//System.out.println(availDM.getWidth() + "x" + availDM.getHeight());
if (availDM.equals(currentDM)){
currentInAvailable = true;
}
}
System.out.println("Current resolution: " + currentDM.getWidth() + "x" + currentDM.getHeight());
System.out.println("Current in available: " + currentInAvailable);
JFrame frame = new JFrame("Resolution Bug Example");
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
if (!gd.isFullScreenSupported()){System.exit(0);}
gd.setFullScreenWindow(frame);
gd.setFullScreenWindow(null);
}
});
}
}
輸出運行1680×1050(顯示器的靠不住的原始分辨率):
如果
run:
Available resolutions:
Current resolution: 1680x1050
Current in available: false
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Invalid display mode
at sun.awt.Win32GraphicsDevice.setDisplayMode(Win32GraphicsDevice.java:393)
at sun.awt.Win32GraphicsDevice.setFullScreenWindow(Win32GraphicsDevice.java:329)
at resolutionexample.Main$1.run(Main.java:43)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
BUILD SUCCESSFUL (total time: 2 seconds)
輸出設置我的分辨率爲1024x768運行前:
run:
Available resolutions:
Current resolution: 1024x768
Current in available: true
BUILD SUCCESSFUL (total time: 2 seconds)
它進入真正的全屏模式,但它不會出來,它也不會響應alt-tab卡住。 現在,我的確在使用與您所描述的類似的假全屏。 :) – Angie 2010-03-29 17:40:36