我写了一个改变字体大小的程序,但字体大小不变,请大家帮我看一下。源程序如下:
import java.awt.*;
import java.applet.*;public class welcome extends Applet implements Runnable
{
Thread thread;
String s="welcome to China!";
int size=20;
Font font; public void start()
{
thread=new Thread();
thread.start();
try
{
Thread.sleep(1000);
}catch(InterruptedException e){}
}
public void init()
{
font=new Font("TimesRoman",Font.BOLD,size);
} public void paint(Graphics g)
{
font=new Font("TimesRoman",Font.BOLD,size);
g.setFont(font);
g.setColor(Color.green);
g.drawString(s,50,50);
}
public void run()
{
try
{
while(true)
{
repaint();
size+=10;
if(font.getSize()>=100)
size=10;
Thread.sleep(1000);
}
}catch(InterruptedException e){}
} public void stop()
{
if(thread.isAlive())
thread.stop();
}
}
import java.awt.*;
import java.applet.*;public class welcome extends Applet implements Runnable
{
Thread thread;
String s="welcome to China!";
int size=20;
Font font; public void start()
{
thread=new Thread();
thread.start();
try
{
Thread.sleep(1000);
}catch(InterruptedException e){}
}
public void init()
{
font=new Font("TimesRoman",Font.BOLD,size);
} public void paint(Graphics g)
{
font=new Font("TimesRoman",Font.BOLD,size);
g.setFont(font);
g.setColor(Color.green);
g.drawString(s,50,50);
}
public void run()
{
try
{
while(true)
{
repaint();
size+=10;
if(font.getSize()>=100)
size=10;
Thread.sleep(1000);
}
}catch(InterruptedException e){}
} public void stop()
{
if(thread.isAlive())
thread.stop();
}
}
import java.applet.*;public class welcome extends Applet implements Runnable {
Thread thread;
String s = "welcome to China!";
int size = 20;
Font font; public void start() {
thread = new Thread(this);
thread.start();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
} public void init() {
font = new Font("TimesRoman", Font.BOLD, size);
} public void paint(Graphics g) {
font = new Font("TimesRoman", Font.BOLD, size);
g.setFont(font);
g.setColor(Color.green);
g.drawString(s, 50, 50);
} public void run()
{
try
{
while(true)
{
repaint();
size+=10;
if((font.getSize())>=100)
size=10;
Thread.sleep(1000);
}
}catch(InterruptedException e){}
} public void stop() {
if (thread.isAlive())
thread.stop();
}
}