当前位置: 代码迷 >> Java相关 >> 绘制剪切文字图形怎么运行不了呀?
  详细解决方案

绘制剪切文字图形怎么运行不了呀?

热度:344   发布时间:2007-04-18 13:19:52.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
搜索更多相关的解决方案: 图形  剪切  绘制  文字  运行  

----------------解决方案--------------------------------------------------------
  相关解决方案