Question 8 First Lines Class Primenumber Shown Public Class Primenumber Extends Jframe Imp Q43785175
Please answer the below question in Java, thankyou.
Question 8 The first few lines of a class PrimeNumber are shown below: public class PrimeNumber extends JFrame implements ActionListener { new JLabel (“2”); = new JButton (“Next Prime”); private JLabel label private JButton button х The expected appearance of the GUI, which includes a label and a button, is shown on the right and the layout manager is the FlowLayout manager. Next Prime Write the constructor PrimeNumber () to generate the GUI and add the object itself as the (a) 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] Show transcribed image text Question 8 The first few lines of a class PrimeNumber are shown below: public class PrimeNumber extends JFrame implements ActionListener { new JLabel (“2”); = new JButton (“Next Prime”); private JLabel label private JButton button х The expected appearance of the GUI, which includes a label and a button, is shown on the right and the layout manager is the FlowLayout manager. Next Prime Write the constructor PrimeNumber () to generate the GUI and add the object itself as the (a) 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]
Expert Answer
Answer to Question 8 The first few lines of a class PrimeNumber are shown below: public class PrimeNumber extends JFrame implement…
OR