danfickle / danfickle/java-bootstrap-laf

Enable antialias when drawing rounded shapes

Open
#1 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
44
Forks
6
PR merge metrics
No merged PRs in 30d

Description

I recommend you to enable antialias when drawing non-square shapes to make them smooth and pretty. For example in your `JBootstrapButtonUI` class:

``` java
@Override
public void paint ( Graphics g, JComponent c )
{
// Enabling antialias
final Graphics2D g2d = ( Graphics2D ) g;
final RenderingHints.Key key = RenderingHints.KEY_ANTIALIASING;
final Object oldAAhint = g2d.getRenderingHint ( key );
g2d.setRenderingHint ( key, RenderingHints.VALUE_ANTIALIAS_ON );

// ... painting code ...

// Restoring previous antialias settings
g2d.setRenderingHint ( key, oldAAhint );
}
```

And don't worry, `Graphics` can be casted to `Graphics2D` without any issues as it is always passed into paint methods, unless you switch graphics debug on (I doubt you will, because it is a really outdated feature).

You can also look into features provided by `Graphics2D` class - there are lots of them.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.