0

When I use SimpleCaptcha, I receive this error:

Exception in thread "main" java.lang.NoSuchMethodError: disposeLater    
 at java.awt.Component.initIDs(Native Method)   
 at java.awt.Component.<clinit>(Component.java:579)     
 at sun.awt.windows.WToolkit.initIDs(Native Method)     
 at sun.awt.windows.WToolkit.<clinit>(WToolkit.java:106)    
 at sun.awt.Win32GraphicsEnvironment.<clinit>(Win32GraphicsEnvironment.java:51)     
 at java.lang.Class.forName0(Native Method)     
 at java.lang.Class.forName(Class.java:169)     
 at javava.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68)
 at java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1135)    
 at nl.captcha.text.renderer.DefaultWordRenderer.render(DefaultWordRenderer.java:65)    
 at nl.captcha.Captcha$Builder.addText(Captcha.java:145)    
 at nl.captcha.Captcha$Builder.addText(Captcha.java:121)    
 at nl.captcha.Captcha$Builder.addText(Captcha.java:111)    
 at com.sohu.nl.test.simpleCaptcha.main(simpleCaptcha.java:29)

This is my code:

public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        System.out.println("test");
        Builder captchaBuilder = new Builder(10, 100);
        captchaBuilder.addText();
        Captcha captcha = captchaBuilder.build();
        File file = new File("D:/a.jpeg");
        ImageIO.write(captcha.getImage(), "JPEG", file);
    }
4

1 に答える 1

0

私は現在このコードを使用しています:

import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import nl.captcha.Captcha;
import nl.captcha.Captcha.Builder;

public class core {


public static void main(String[] args) {
    Builder c = new Builder(200, 150);
    c.addText();
    Captcha captcha = c.build();
    File file = new File("C:/a.jpeg");
    try {
        ImageIO.write(captcha.getImage(), "JPEG", file);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
}

チェックアウト: http://docs.oracle.com/javase/7/docs/api/java/lang/NoSuchMethodError.html

于 2012-11-01T17:10:04.570 に答える