Question: Question 8 The first few lines of a class PrimeNumber are shown below: public class PrimeNumber extends JFrame implements ActionListener { private JLabel label =

Question 8 The first few lines of a class PrimeNumber are shown below: public class PrimeNumber extends JFrame implements ActionListener { private JLabel label = new JLabel("2"); private JButton button = new JButton ("Next Prime"); U DO The expected appearance of the GUI, which includes a label and a button, is Next Prime shown on the right and the layout manager is the FlowLayout manager. (a) Write the constructor PrimeNumber() to generate the GUI and add the object itself as the action listener of the button. When the window is closed, the program should terminate. [2 marks] (b) When the button is pressed, the next (larger) prime number is displayed on the label. Write the method actionPerformed () to perform this action. [3 marks]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
