Question: Use java programming for the following questions to have the solutions ready within today Jan 3 2020 at or before 8:00PM GMT+8 time zone: Question
Use java programming for the following questions to have the solutions ready within today Jan 3 2020 at or before 8:00PM GMT+8 time zone:
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");
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.
- 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.
- When the button is pressed, the next (larger) prime number is displayed on the label. Write the method actionPerformed() to perform this action.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
