Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Converting pixels to cm?

807605Jul 18 2007 — edited Aug 16 2007
Hi all,

I have this code:
Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension screen = tk.getScreenSize();     
        if(((height=screen.getHeight())>=768)&&
            ((width=screen.getWidth())>=1024)) 
        {
            //Do nothing. Variables width and height already set inside if condition.
        } 
where variables height and width are in pixels.

However in another part of my program i want to set the position of a JLabel . From what i understand the setPosition method requires cm.

Can anyone tell me how to convert pixels to cm in a safe way.

Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 13 2007
Added on Jul 18 2007
31 comments
714 views