Random() メソッドの生成に基づいてランダムな画像を表示しようとしています(キャプチャのようなものを試しているだけです)。配列からランダムな番号を生成していますが、これらの番号を画像にマップする方法がわかりません。何か案は ?私が今までやってきたこと:
java.util.Arrays をインポートします。java.util.Random をインポートします。
public class Gen_Captcha {
static String[] myCaptchaLetters = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9"};
Gen_Captcha captcha= new Gen_Captcha();
public static void main(String[] args) {
Random randomGenerator = new Random();
for(int i=0;i<5;i++){
int random = randomGenerator.nextInt(62);
System.out.print((myCaptchaLetters[random]));
}
}
}
}
注: 上記のコードには、画像を表示するためのスイング フレームワーク コードが含まれていません。