4 class DrawingCanvas
extends Canvas
{
5 public DrawingCanvas() {
8 public String text
= new String("LOOOL");
9 public void paint(Graphics g
) {
10 createBufferStrategy(2); //double buffered
12 Graphics2D g2D
=(Graphics2D
) g
; // cast to 2D
13 g2D
.setRenderingHint(RenderingHints
.KEY_ANTIALIASING
,
14 RenderingHints
.VALUE_ANTIALIAS_ON
);
17 g
.drawRect(0, 0, 99, 49); // draw border
18 g
.drawString(text
, 20,20);
23 public static void main(String
[] args
) throws InterruptedException
{
24 JFrame window
= new JFrame();
25 window
.setDefaultCloseOperation(JFrame
.EXIT_ON_CLOSE
);
26 window
.setSize(640,480);
27 window
.setTitle("hello");
28 window
.setVisible(true);
30 DrawingCanvas canvas
= new DrawingCanvas();
31 window
.getContentPane().add(canvas
);
This page took 0.301757 seconds and 4 git commands to generate.