tags:

views:

204

answers:

2

I have a question. When I'm setting the size of a JFrame and I add a new dimension. Is that number millimeter or pixels? I want to set the size to 3in by 3in. So I'm using (300, 300) but it seems a little big. How do I set the size in inches?

Cool this is how I solved it in case someone wants to know:

// Get a Toolkit instance.
Toolkit tk = Toolkit.getDefaultToolkit ();

// Get resolution in pixels per inch.
int pixels_per_inch = tk.getScreenResolution ();
+3  A: 

The argument is in pixels.

Using information from the Toolkit, you can convert inches to pixels.

If you are going to use Java 2D (which is recommended for the best quality), you can also use a normalizing transform.

erickson
nice find on that Toolkit method (also nice family name =)
maerics
+1  A: 

I believe that all AWT/Swing dimensions are pixels, unless otherwise stated. The conversion of pixels per inch is device independent, meaning each display (or printer, etc.) will have it's own pixel density.

maerics