Solved

How to known if OS is running more than 1 monitor.

Posted on 2001-06-08
5
246 Views
Last Modified: 2012-06-21
I have two monitors. I am running an application in the second monitor and saves cordinates in a file. When I move the application to another computer that only have 1 monitor the window is not visible due to location outside the monitor.


Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

gets me 1600x1200
But my windows is located lets say 1680x150 and not visible.
I could remove 1600 from the 1680 automatically. But I want to support more monitors.

There is a method
Toolkit.getDefaultToolkit().getDesktopProperty(StringPopertyName);

Does anyone know what property I should look for?
Or some way to ask the OS number of monitors etc.
0
Comment
Question by:lawpan
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:dnoelpp
ID: 6167941
Please have a look at:

http://java.sun.com/j2se/1.3/docs/guide/awt/enhancements.html

They tell you how to support more than one monitor.

I will look for a solution working in Swing. Stay tuned.
0
 
LVL 3

Accepted Solution

by:
dnoelpp earned 150 total points
ID: 6167993
Try the following code:

GraphicsDevice[] devices = GraphiceEnvironment.getLocalGraphicsEnvironment().getScreenDevices();

System.out.println("device count: " + devices.length);

// Select default configuration of screen 0:

GraphicsConfiguration gc0 = devices[0].getDefaultConfiguration();

// create a JFrame on screen 0
JFrame f = new JFrame(gc0);

// Select default configuration of screen 1, if existent, or throw IndexOutOfBoundsException

GraphicsConfiguration gc1 = devices[1].getDefaultConfiguration();

// create a JFrame on screen 1
JFrame f = new JFrame(gc1);


* * * * * * *

The idea is: A GraphicsDevice describes a device you can paint on. This is a screen, a printer, etc.

Each device now has several configurations. Maybe for screens it is meant: color or black and white. But I think just take the default configuration and you should be fine. Then pass that configuration to the Frame or a JFrame-constructor. And that's it!
0
 
LVL 3

Expert Comment

by:dnoelpp
ID: 6168072
Oops, a typo! Should be GraphicsEnvironment instead of GraphiceEnvironment.

Sorry!
0
 

Author Comment

by:lawpan
ID: 6176003
Thank you very much. This was what I was looking for.
0
 

Author Comment

by:lawpan
ID: 6180041
Thank you very much. This was what I was looking for.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java Options in Zimbra Server 2 52
replace a word with other 1 44
even odd program using while loop 3 40
check java version using powershell 13 91
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question