Develop an application which shows a button and a label on the screen. Each time the button is pushed, the label will show a random number between 1 and 100. You will require two classes in order to employ this.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.Random;
public class Random
{
public static void main(String[] args)
{
JFrame frame = new JFrame("Pick A Number");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Random panel = new Random();
frame.getContentPane().add(new RandomPanel());
frame.pack();
frame.setVisible(true);
}
}