Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.RenderingHints;
- import java.awt.image.BufferedImage;
- import javax.swing.JPanel;
- class XGraphic extends JPanel {
- // Paint event with Anti-Aliasing
- private void AApaint(Graphics2D g) {
- // DRAW HERE
- }
- // Sets up paint event with antialiasing enabled
- public void paint(Graphics graphics) {
- Graphics2D g = (Graphics2D) graphics;
- BufferedImage image = new BufferedImage(this.getWidth(), this.getHeight(), BufferedImage.TYPE_INT_RGB);
- Graphics2D ig = image.createGraphics();
- ig.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- AApaint(ig);
- g.drawImage(image, null, this);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement