Reputation: 44114
I'm rewriting an application that was previously layed out and rendered manually on one big canvas (a fullscreen wallboard) to use Swing, but I get some quality issues with rendering text and scaled images.
In the old app my render method just enabled some settings on the Graphics2D
object before drawing the entire screen:
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
But in the new version the drawing is distributed over various components, with no 1 root method. So how can I do the equivalent in Swing?
Upvotes: 2
Views: 1042
Reputation: 285405
I believe that all child components get their Graphics object from their parent component. So if you set the rendering hints for the parent's Graphics object in its paint
method (or its paintChildren
method if the parent component doesn't need to have its rendering hints set) and then called the super method, it will likely work. You'll not want to do this for the whole GUI though as it can slow down rendering.
Upvotes: 3