drawString, Font, & FontMetrics
class MyCanvas extends Canvas {
public void paint(Graphics g){
g.setFont(new Font("Dialog",0,20));
FontMetrics fm = g.getFontMetrics();
int x = 100;
int y = 100;
g.drawString("Hello",x,y);
y = y+fm.getHeight();
g.drawString("World",x,y);
}
}
Previous slide
Next slide
Back to first slide
View graphic version