2013-05-14 225 views
2

我有一個Java應用程序,它在兩個獨立的顯示器上顯示兩個JFrame。在Ubuntu和Windows上,應用程序顯示得很好。我可以將JFrames配置爲在具有指定屏幕ID的監視器上顯示。然而,在openSUSE中,無論設置如何,它都會在相同的顯示器上顯示。與openSUSE有什麼不同?OpenSuse 12.3 + Java雙顯示器

下面是一些我用它來確定哪個監視JFrame中必須顯示的代碼:


    GraphicsDevice[] screens = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); 
    for (int s = 0; s < screens.length; s++) { 
     GraphicsConfiguration configuration = null; 
     for (int c = 0; c < screens[s].getConfigurations().length; c++) { 
      if (AWTUtilities.isTranslucencyCapable(screens[s].getConfigurations()[c])) { 
       configuration = screens[s].getConfigurations()[c]; 
       break; 
      } 
     } 
     if (configuration == null) { 
      configuration = screens[s].getDefaultConfiguration(); 
     } 
     if (screens[s].getIDstring().equals[frame1_id]) { 
      frame1 = new JFrame("Frame 1", configuration); 
      frame1.setResizable(false); 
      frame1.setUndecorated(true); 
      frame1.setBounds(configuration.getBounds()); 
      frame1.setVisible(true); 
     } 
     if (screens[s].getIDstring().equals[frame2_id]) { 
      frame2 = new JFrame("Frame 2", configuration); 
      frame2.setResizable(false); 
      frame2.setUndecorated(true); 
      frame2.setBounds(configuration.getBounds()); 
      frame2.setVisible(true); 
     } 
    } 
+1

你試過不同的窗口管理器嗎? – trashgod

+1

這對我很有用,非常感謝。請添加您的評論作爲答案,以便我可以投票。 – bouncer

+0

很高興幫助。如果您有關於最佳效果的詳細信息,我會將其納入答案中。你也可以[回答你自己的問題](http://meta.stackexchange.com/q/17463/163188)。 – trashgod

回答

1

openSUSE的實施GraphicsEnvironment可能取決於特定的窗口管理器的選擇。你必須嘗試找到最優的一個。

附錄:@bouncer評論:「我使用了Gnome窗口管理器,這導致了問題。切換到KDE後,問題解決了。」另見10 things to do after installing openSUSE 12.3

+1

我使用了Gnome窗口管理器,這導致了問題。切換到KDE後,問題解決了。 – bouncer