Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2001-06-08
5
Medium Priority
?
279 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 600 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

916 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