danfickle / danfickle/java-bootstrap-laf
Enable antialias when drawing rounded shapes
- Lingua principale
- Java
- Stelle
- 44
- Fork
- 6
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.