Solved

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

Posted on 2001-06-08
5
269 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

623 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