2013-05-14 202 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