Handle screen updates : RenderHints « 2D Graphics « Java Tutorial






Handle screen updates
import java.awt.Graphics;

import javax.swing.JComponent;
import javax.swing.JFrame;

class MyCanvas extends JComponent {

  public void paint(Graphics g) {
    g.drawString (Long.toString(System.currentTimeMillis()), 10, 30); 
    repaint(1000);
  }
}

public class SettingFont {
  public static void main(String[] a) {
    JFrame window = new JFrame();
    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    window.setBounds(30, 30, 300, 300);
    window.getContentPane().add(new MyCanvas());
    window.setVisible(true);
  }
}








16.45.RenderHints
16.45.1.Handle screen updatesHandle screen updates
16.45.2.Set Rendering Hint and EllipseSet Rendering Hint and Ellipse
16.45.3.The five new fields in java.awt.RenderingHints class:
16.45.4.RenderingHints.KEY_TEXT_ANTIALIASING
16.45.5.RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HBGR
16.45.6.RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB
16.45.7.RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VBGR
16.45.8.RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VRGB
16.45.9.RenderingHints.VALUE_TEXT_ANTIALIAS_ON