File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Monitor Size Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Monitor Size" Watch "Monitor Size" New topic
Author

Monitor Size

chiru
Greenhorn

Joined: Jan 31, 2008
Posts: 7
How to Calculate the size of Monitor like 17" 15"


-chiru
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

Originally posted by chiru:
How to Calculate the size of Monitor like 17" 15"


The Toolkit class will has methods to get the screen size as well as the screen resolution, based on which you can compute the Monitor size.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
chiru
Greenhorn

Joined: Jan 31, 2008
Posts: 7
i'm calculateing like this but i think it is not giveing exact value if i change the resolution of dispaly
Dimension screen = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
int pixelPerInch=java.awt.Toolkit.getDefaultToolkit().getScreenResolution();
double height=screen.getHeight()/pixelPerInch;
double width=screen.getWidth()/pixelPerInch;
double x=Math.pow(height,2);
double y=Math.pow(width,2);
jLabel1.setText("Res"+screen.getHeight()+"X"+screen.getWidth()+"Pixel/Inch"+pixelPerInch+" "+x+" "+y+"="+Math.sqrt(x+y));
Mark Newton
Ranch Hand

Joined: Jan 31, 2006
Posts: 129
What do you think is wrong with it? I've just run it and seem to get realistic output.

I assume you're not expecting an exact answer like 15 inches - a 15 inch monitor will have an actual screen size of slightly less.

[Edit: punctuation]
[ February 07, 2008: Message edited by: David Payne ]
chiru
Greenhorn

Joined: Jan 31, 2008
Posts: 7
but if i run this code in 17" monitor which is having same resolution it is giving 15. somthing..
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Chiru.

Please check your private messages.


GenRocket - Experts at Building Test Data
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Monitor Size