g.drawString(ch[index]+"", i*15+3, 18);
这句代码一直报错,为什么
The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
在MyEclipse中的配置方式为:右击项目->configuration buildPath->选择jre8->remove->add library->JRE SystemLibrary->jre6。这样就能解决嘿嘿
我也遇到了,唉
BufferedImage bi=new BufferedImage(68, 32, BufferedImage.TYPE_INT_BGR);
Graphics g=bi.getGraphics();
Color c=new Color(200,150,255);
g.setColor(c);
g.fillRect(0, 0, 68, 32);
char[] ch="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toCharArray();
Random r=new Random();
int len=ch.length,index;
StringBuffer sb=new StringBuffer();
for(int i=0;i<4;i++){
index=r.nextInt(len);
g.setColor(new Color(r.nextInt(79),r.nextInt(135),r.nextInt(202)));
g.drawString(ch[index]+"", (i*15)+3, 18);
sb.append(ch[index]);
}
request.getSession().setAttribute("piccode", sb.toString());
ImageIO.write(bi, "JPG", response.getOutputStream());