Rotem E
Rotem E

Reputation: 213

How to draw in high resolution in Swing?

Is there is a way to draw in high resolution in Swing? I tried to draw a simple shapes and the resolution of these shapes is very low.

Upvotes: 2

Views: 784

Answers (2)

Jedi_Maseter_Sam
Jedi_Maseter_Sam

Reputation: 813

You can try turning anti-aliasing on.

public void paint(Color c, Polygon p, Graphics g){
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHints(new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2d.setColor(c);
g2d.fillPolygon(p);
}

There is also more documentation here

Upvotes: 3

user3437460
user3437460

Reputation: 17454

You probably can't control the resolution in Swing, but you can use the rendering hints attribute from Graphics2D to tweak on the rendering quality:

Use the Graphics2D class rendering hints attribute to specify whether you want objects to be rendered as quickly as possible or whether you prefer that the rendering quality be as high as possible.

Take a look here: Controlling Rendering Quality

Upvotes: 6

Related Questions