rendered paste bodyimport java.util.*;//import java.awt.*;import java.awt.event.*;import java.awt.geom.*;import javax.swing.*;//public class Test2_Graph extends JFrame{private /**final*/ static char[] chars;private /**final*/ static Random random;private int length;private String randStr;///////////////////////////////////public Test2_Graph() { super( "Random Image Gen." ); getContentPane().setBackground( Color.gray ); chars = new char[61]; for (int i = 0; i < 26; i ++) { chars[i] = (char) (97 + i); //97-122 // chars[i + 13 ] = (char) (97 + i); //97-122 chars[i + 26] = (char) (65 + i); //65-90 //chars[51] = ']'; // chars[i + 52] = (char) (48); //48-57 } for (int i = 0; i < 9; i ++) { chars[i + 52] = (char) (49 + i); //48-57 } random = new Random (); }///////////////END CONSTRUCTOR public void paint( Graphics g ) { drawText( g ); } public void drawText( Graphics g ) { super.paint( g ); Graphics2D graphics2D = ( Graphics2D ) g ; graphics2D.setFont(new Font("Goudy Handtooled BT", Font.PLAIN, 100)); graphics2D.setPaint(Color.orange);// graphics2D.drawString("Java 2D", 25, 115); graphics2D.drawString(randStr, 25, 115); } /////////////////////////////////// /** Taking the following section and adding it to Constructorstatic { chars = new char[61]; for (int i = 0; i < 26; i ++) { chars[i] = (char) (97 + i); //97-122 // chars[i + 13 ] = (char) (97 + i); //97-122 chars[i + 26] = (char) (65 + i); //65-90 //chars[51] = ']'; // chars[i + 52] = (char) (48); //48-57 } for (int i = 0; i < 9; i ++) { chars[i + 52] = (char) (49 + i); //48-57 } random = new Random (); } */ private int generate(int x, int y) {// x = 5;// y = 6; int range = y - x + 1; int rangeX; //return (Math.random() * range) + x; rangeX = (int)(Math.random() * range) + x; return length = rangeX;} private String randomString (int length) { //tried to convert into using Math.random instead of having to import// Class RANDOM but MATH uses DOUBLES, and since with// Arrays when setting the # of elements, you must use INT, seems like it'd be//best/only possible?/efficient to use class Random instead of Math.random in//this case? char[] array = new char[length]; for (int i = 0; i < length; i ++) { array[i] = chars[random.nextInt (chars.length)]; } String autoStr = new String(array); randStr = autoStr; return new String (array); } public static void main (String[] args) { Test2_Graph test2 = new Test2_Graph(); System.out.println(test2.randomString(test2.generate(5,6)) + "\n" ); System.out.println("hello " + chars[60] + " helo"); //////////////////////////////////// // Test2_Graph application = new Test2_Graph (); test2.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); test2.setSize( 425, 170 ); test2.setVisible( true ); //////////////////////////////////// } }