标题:绘制剪切文字图形怎么运行不了呀?
只看楼主
hua_jing
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-4-17
 问题点数:0 回复次数:0 
绘制剪切文字图形怎么运行不了呀?
import java.awt.event.*;
import java.awt.font.*;
import java.awt.geom.*;
import javax.swing.*;
import java.awt.*;
public class cc extends JApplet
{
private Shape clipShape;
public void paint(Graphics g)
{
Graphics2D g2=(Graphics2D)g;
clipShape=makeClipShape(g2);
g2.draw(cliShape);
g2.clip(cliShape);
final int NLINES=90;
Point2D p=new Point2D.Double(0,0);
for(int i=0;i<NLINES;i++)
{
double x=(2*getWidth()*i)/NLINES;
double y=(2*getHeight()*(NLINES-1-i))/NLINES;
Point2D q=new Point2D.Double(x,y);
g2.draw(new Line2D.Double(p,q));
}
}
Shape makeClipShape(Graphics2D g2)
{
FontRenderContext context=g2.getFontRenderContext();
Font f=new Font("隶书",Font.PLAIN,80);
GeneralPath clipShape=new GeneralPath();
TextLayout layout=new TextLayout("Hello",f,context);
AffineTransform transform=AffineTransform.getTranslateInstance(0,80);
Shape outline=layout.getOutline(transform);
clipShape.append(outline,false);
layout=new TextLayout("你好!",f,context);
transform=AffineTransform.getTranslateInstance(0,170);
outline=layout.getOutline(transform);
clipShape.append(outline,false);
return clipShape;
}
}
怎么通不过呀,我是抄的书的呀,提示的错为:cannot find symbol variable cliSahpe
搜索更多相关主题的帖子: 图形 剪切 绘制 文字 运行 
2007-04-18 13:19



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-132832-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.921778 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved