Menu

First Lines Class Primenumber Shown Public Class Primenumber Extends Jframe Implements Act Q43785584

The first few lines of a classPrimeNumber are shown below:

public classPrimeNumber extends JFrame implements ActionListener { privateJLabel label = new JLabel(“2”);

89GNFFUparEAAAAAElFTkSuQmCCprivate JButton button = newJButton(“Next Prime”);

The expectedappearance of the GUI, which includes a label and a button, isshown on the right and the layout manager is the FlowLayoutmanager.

  1. Write the constructor PrimeNumber() to generate the GUI and addthe object itself as the action listener of the button. When thewindow is closed, the program should terminate.

  1. When the button is pressed, the next (larger) prime number isdisplayed on the label. Write the method actionPerformed() toperform this action.

Expert Answer


Answer to The first few lines of a class PrimeNumber are shown below: public class PrimeNumber extends JFrame implements ActionLis…

OR