GUI
package Trial;
import java.util.Random;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class Demo2 {
JFrame frame;
public Demo2() {
frame = new JFrame("Hancie e-Learning Studio");
frame.setSize(650, 450);
frame.setLocationRelativeTo(null);
frame.getContentPane().setLayout(null);
Random rand=new Random();
int random=(int) (Math.random()*500+1);
JTextField t1=new JTextField();
t1.setText(String.valueOf(random));
t1.setBounds(10,10,200,35);
frame.add(t1);
frame.setVisible(true);
}
public static void main(String[] args) {
new Demo2();
}
}
Output