简体   繁体   中英

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM