xnee-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xnee-devel] Switching screen resolution moves my program window and xne


From: Veijo Ryhänen
Subject: [Xnee-devel] Switching screen resolution moves my program window and xnee cannot follow it.
Date: Wed, 11 Jan 2006 13:36:11 +0200

Hello,

I have recorder several xnee -tests in 1024x768 screen resolution, but
I cannot play back them in 1280x1024 -resolution, because
my program window position in screen is changed every time
when screen resolution is changed and there is no --offset x,y
-switch available in cnee.

Should I throw away my old xnee -tests and start to record new
tests with 1280x1024 resolution ? Other developers seems to prefer
1280x1024 resolution and it is not good if they have to change
their screen resolution if they would like to run tests which I have
recorded.
As a matter of fact, every programs we have write in java use
this same window screen position technology as showed in
this sample code attachment.

To compile sample code:
javac CenteredWindow.java

To run sample code:
java CenteredWindow

Veijo Ryhänen, Finland.

- - - -

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * Title:       CenteredWindow
 * Description: Opens fixed-size window which is allways centered on the screen -> Upper left corner
 * position moves (=offset) when screen resolution is changed -> xnee replay does not work
 * after screen resolution change, because window location is changed too and there is
 * no "--offset x,y" -switch currently available in xnee or cnee.
 *"--recorded-resolution 1024x768 --replay-resolution 1280x1024" -switches does not help in this case.
 *
 * Sample outputs to console when running in two different screen resolutions:
 * Upper left corner inserted to: 12,34  ScreenSize:1024.0,768.0  WindowSize:1000.0,700.0
 * Upper left corner inserted to: 140,162  ScreenSize:1280.0,1024.0  WindowSize:1000.0,700.0
 *
 * @author Veijo Ryhänen, changes: $Author: $
 *         $Date: $
 *         $Revision: $
 */
public class CenteredWindow extends Frame
{
    public CenteredWindow()
    {
       this.setSize(1000,700);
       Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
       Dimension frameSize = this.getSize();
       /* These should use in real life where smaller resolutions are possible:
       if (frameSize.height > screenSize.height)
       {
           frameSize.height = screenSize.height;
       }
       if (frameSize.width > screenSize.width)
       {
           frameSize.width = screenSize.width;
       }
       */
       int horOffset=(screenSize.width - frameSize.width) / 2;
       int verOffset=(screenSize.height - frameSize.height) / 2;
       this.setLocation(horOffset,verOffset);
       String title="Upper left corner inserted to: "+horOffset+","+verOffset
                    +"  ScreenSize:"+screenSize.getWidth()+","+screenSize.getHeight()
                    +"  WindowSize:"+this.getSize().getWidth()+","+this.getSize().getHeight();
       System.out.println(title);
       this.setTitle(title);
       this.show();

       this.addWindowListener (new WindowAdapter()
       {
           public void windowClosing (WindowEvent e)
           {
              System.exit(0);
           }
       });
    }

    public static void main(String[] args)
    {
       CenteredWindow cw = new CenteredWindow();
    }
}


reply via email to

[Prev in Thread] Current Thread [Next in Thread]