Issue
How would I display a random number into a text field on jFrame? My method for generating a random number is in a different class.
Random rn = new Random();
int i = rn.nextInt(51);
System.out.println(i);
How would I make the number appear in the textfield?
Solution
You don't have to use a seperate class.
Just do as following.
Random rn = new Random();
JTextField textField = //initialize your text field here
Then set the random number as,
textField.setText(Integer.toString(rn.nextInt(51)));
Answered By - Minudika Malshan Gammanpila
Answer Checked By - Marilyn (JavaFixing Volunteer)