Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Screen resolution

 
Lila Fowler
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

I'm trying to get the screen resolution (eg: 1152 x 864) of a pc that is currently running the program, but i cant seem to get it to work.

Iv changed the the resolution a couple of time but i always get the same result 96 but i think its because it takes the whole screens pixels per inch?



Is there a way to get the current resolution that is being used?

thanks
 
Oleg Tikhonov
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Did you try like that?



Hope it helps.
 
Oleg Tikhonov
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for more information look at Toolkit
 
salvin francis
Bartender
Posts: 1274
10
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lila Fowler wrote:hi all,

I'm trying to get the screen resolution (eg: 1152 x 864) of a pc that is currently running the program, but i cant seem to get it to work.

Iv changed the the resolution a couple of time but i always get the same result 96 but i think its because it takes the whole screens pixels per inch?



Is there a way to get the current resolution that is being used?

thanks


its called ppi (pixels per inch)
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Screen size and screen resolution are two different things.
Size refers to the well size of your monitor
Resolution will give you the density of the pixels.I think it is dots per inch (dpi)

The Toolkit class has methods for retrieving both these parameters.
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving thread to our GUIs forum.
 
Lila Fowler
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, i am looking for the resolution, not the screen size. when i run that code it only returns 96 no matter what i make the resolution. Is there a way to get the current resolution being used. eg: 1280 by 720?

thanks
 
Karthick Dharani Vidhya
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Did you try



I checked it with my resolution as 1280 * 1204. Screen Size's width was returned as 1280 and height was returned as 1204.
I changed my resolution to 1280 * 800. Screen Size's width was returned as 1280 and height was returned as 800.

May be you can try that and check.
 
salvin francis
Bartender
Posts: 1274
10
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:Screen size and screen resolution are two different things.
Size refers to the well size of your monitor
Resolution will give you the density of the pixels.I think it is dots per inch (dpi)

The Toolkit class has methods for retrieving both these parameters.

dpi is related to printing.
its the dots per inch on paper, hence the term "dot" as opposed to "pixel"
http://en.wikipedia.org/wiki/Pixel_density
http://en.wikipedia.org/wiki/Dots_per_inch

Lila Fowler, the answer provided by Oleg Tikhonov is correct, have you tried that?
 
Lila Fowler
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just finished trying it, thanks it works great, but now im really confused because i thought that getScreenSize returned the actual measurements of the screen itself. Sorry, Thanks for all your help.
 
Karthick Dharani Vidhya
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. It does return the size of the screen. BUT NOT THE PHYSICAL SIZE.

It returns you the PIXEL SIZE OF THE SCREEN. Like 1024 * 768. You can accomodate these many number of pixels in this screen.
Obviously, when your resolution changes, the number of pixels that you can accomodate (i.e the size) changes
 
salvin francis
Bartender
Posts: 1274
10
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lila Fowler wrote:I just finished trying it, thanks it works great, but now im really confused because i thought that getScreenSize returned the actual measurements of the screen itself. Sorry, Thanks for all your help.


Do you mean Monitor size like 15inch or 17inch ?
If yes,
I confess i do not know how that can be achieved, and i am curious to why do you require that info..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic