Jump to content

Applet


Gurzi

Recommended Posts

Boas..

Estou a ler um daqueles livros "Teach Yourself Java in 21 days"

e no ínicio falam de applets e queria ver o resultado só que o code de uma das páginas nao aparece logo nçao sei o que está em java.applet.Applet

Alguem tem ideia do código que falta ?

o outro é

import java.awt.Graphics;
import java.awt.Font;
import java.awt.Color;

public class HelloAgainApplet extends java.applet.Applet{
Font F = new Font("TimesRoman", Font.Bold,36);

public void paint(Graphics g){

g.setFont(f);
g.setColor(Color.red);
g.drawString("Hello again",5,25);

}

Link to comment
Share on other sites

Não percebi a primeira pergunta.

Quanto ao outro assunto.

import java.awt.Graphics;
import java.awt.Font;
import java.awt.Color;

public class HelloAgainApplet extends java.applet.Applet{

Font f = new Font("TimesRoman", Font.BOLD,36); // Font.BOLD e nao Font.Bold.

public void paint(Graphics g){
	g.setFont(f); // 'f' ou 'F' java e case sensitive
	g.setColor(Color.red);
	g.drawString("Hello again",5,25);
} // Faltava esta chaveta.
}

O código compilou e correu sem problemas.

Cumps 👍

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.