danfickle / danfickle/java-bootstrap-laf
Enable antialias when drawing rounded shapes
- 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.