سؤال

I am developing an application in Swing. When I have two monitors connected, the application will not display. The icon appears in the unity side bar but the window is nowhere to be seen.

I went back to basics and ran HelloWorldSwing.java from the Oracle tuorials

http://docs.oracle.com/javase/tutorial/uiswing/examples/start/HelloWorldSwingProject/src/start/HelloWorldSwing.java

and the same problem exists. Then I find that if I put Monitor 1 on the left, HelloWorld appears in the top left hand corner.

How can I get HelloWorldSwing (and Swing apps in general) to display in Unity when the main monitor is on the right?

My display configuration: Monitor 1 (Laptop Screen) 1280x800 Monitor 2 ("unknown") 1440x900

Monitor 2 is on the left. I have the following in my ~/.xprofile:

xrandr --newmode "1680x1050" 146.25  1680 1784 1960 2240  1050 1053 1059 1089 -hsync +vsync
xrandr --addmode VGA1 1680x1050
xrandr --newmode "1440x900" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync
xrandr --addmode VGA1 1440x900
هل كانت مفيدة؟

المحلول

Okay it's a simple as

private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("HelloWorldSwing");
    frame.setLocation (50, 50);
    ...

setLocation copes just fine with the multiple monitors. It's just that the default location (if setLocation is not called) appears to be off screen when monitor 2 is left.

0,0 is at the top left on the left monitor as expected. However if you use setLocation(0,0) the window's close / minimize / maximize buttons are obscured by the unity top bar.

I guess some platform-specific stuff is required to integrate with the unity top bar / side bar.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top