[英]Java - How to launch my application still, where my PC, has only DVI output which requires to convert to VGA monitors
當我只有一台PC時,DVI輸出和監視器是VGA輸入(所以我使用了一個小的DVi到VGA轉換器,我的操作系統是顯示器)
Linux顯示查詢顯示以下內容:
$ export DISPLAY=:0.0 && xrandr
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 640 x 480, current 1280 x 1024, maximum 1280 x 1024
default connected 1280x1024+0+0 0mm x 0mm
1280x1024 0.0*
1024x768 0.0
800x600 0.0
640x480 0.0
legend (0x10c) 74.5MHz
h: width 1280 start 1344 end 1472 total 1664 skew 0 clock 44.8KHz
v: height 720 start 723 end 728 total 748 clock 59.9Hz
-我的Java應用程序在啟動時感到困惑,並且無法啟動該應用程序,但異常來自dm.getWidth();
:
screen = Toolkit.getDefaultToolkit().getScreenSize();
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] screenDevices = ge.getScreenDevices();
for (int i = 0; i < screenDevices.length; i++) {
System.out.println(screenDevices[i].getIDstring());
DisplayMode dm = screenDevices[i].getDisplayMode();
int screenWidth = dm.getWidth(); // this fails....
int screenHeight = dm.getHeight();
System.out.println("[myResolution]: " + screenWidth + " " + screenHeight);
screen.width = screenWidth;
screen.height = screenHeight;
}
- 輸出:
[meJavaDebug]: YES i am running
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at main.YumYumYum.createAndShowGUI(YumYumYum.java:167)
at main.YumYumYum.access$000(YumYumYum.java:42)
at main.YumYumYum$1.run(YumYumYum.java:118)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:226)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:647)
at java.awt.EventQueue.access$000(EventQueue.java:96)
at java.awt.EventQueue$1.run(EventQueue.java:608)
at java.awt.EventQueue$1.run(EventQueue.java:606)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:617)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
Total Garbage Collections: 0
Total Garbage Collection Time (ms): 0
任何想法?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.