Solved

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

Posted on 2001-06-08
5
259 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 239
Oracle SQL syntax check  without executing 6 107
Opening PDF on button click and fill new document 2 54
jmss example java 2 32
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…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

749 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