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 ();
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.