import java.awt.*;
public class FontTest extends java.applet.Applet {
String str;
public void init() {
repaint();
}
public void paint(Graphics g) {
Dimension d = size();
Image screen = createImage(d.width, d.height / 2);
Graphics ng = screen.getGraphics();
ng.setColor(Color.black);
ng.drawString("using Graphics object of the image", 50, d.height / 4);
g.drawImage(screen, 0, 0, null);
g.setColor(Color.black);
g.drawString("using Graphics object from the paint Method"
, 50, (d.height / 2) + 20);
}
}
both strings are printed with different fonts.
public class FontTest extends java.applet.Applet {
String str;
public void init() {
repaint();
}
public void paint(Graphics g) {
Dimension d = size();
Image screen = createImage(d.width, d.height / 2);
Graphics ng = screen.getGraphics();
ng.setColor(Color.black);
ng.drawString("using Graphics object of the image", 50, d.height / 4);
g.drawImage(screen, 0, 0, null);
g.setColor(Color.black);
g.drawString("using Graphics object from the paint Method"
, 50, (d.height / 2) + 20);
}
}
both strings are printed with different fonts.