Graphics Contexts
void paint (Graphics g) {
int x=100; int y=50; int w=100; int h=50;
int x2=300; int y2=150;
g.drawString(“Hello”, x, y); // Draws text
g.setFont(new Font(“Helvetica”, Font.BOLD 20));
g.drawString(“Hello again”, x, y2);
g.setColor(Color.red);
g.drawLine(x1, y1, x2, y2);
g.drawRect(x, y, w, h);
g.fillRect(x, y, w, h);
g.drawOval(x, y, w, h);
}
Previous slide
Next slide
Back to first slide
View graphic version