跪求一段能实现关键字变色的完整程序!

来源:百度知道 编辑:UC知道 时间:2024/05/17 02:35:36
最近因为工作需要,要编写一个“SQL查询分析器”,要求这个分析器要用shell窗口显示,我本想用JTextPane实现,可是在shell窗品中显示JTextPane却一直没有成功,哪位朋友有这样的程序或有什么好的思想,请帮帮我!或者能帮我实现在shell显示JTextPane也行,最好是完整的程序,我最近急需这段代码,请各位帮帮忙,先谢谢啦!

//RainbowText.java
import java.applet.Applet;
import java.awt.*;

public class RainbowText extends Applet
implements Runnable
{
//变量定义
String str = null;
int strlen = 0;
Thread runner = null;
char theChars[] = null;
int charOffsets[] = null;
Color colors[] = null;
int phase = 0;
Image offScreenImage = null;
Graphics offScreenG = null;
Font f = null;
FontMetrics fm = null;

//初始化小程序
public void init()
{
int i = 20;
str = getParameter("text");
if(str == null)
str = "Museum of Java Applets";
f = new Font("TimesRoman", 1, 36);
fm = getFontMetrics(f);
resize(40 + fm.stringWidth(str), 40);
setBackground(Color.black);
strlen = str.length();
theChars = new c