Question
The application JFacts contains a JFrame, a label, and six random facts. Every time the user clicks the JButton, remove replace the label's text and
The application JFacts contains a JFrame, a label, and six random facts. Every time the user clicks the JButton, remove replace the label's text and add a different one. The facts should cycle in order, fact 1 to fact 6. When the JButton is pressed on face 6, the program should display fact 1 again.
***MUST KEEP GIVEN CODE INTACT***
JFacts.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JFacts extends JFrame implements ActionListener {
FlowLayout flow = new FlowLayout();
JButton b = new JButton("Press to change fact");
JLabel stars = new JLabel("**********************************************");
JLabel fact = new JLabel();
String[] quotes = new String[]{"Only seven prisoners were in the Bastille when it was stormed. ",
"A Tale of Two Cities is a novel set during the French Revolution. ",
"Perhaps 40,000 people were executed at the guillotine. ",
"A loaf of bread cost a weeks wages prior to the French Revolution. ",
"Thomas Jefferson was the U.S. Minister to France during the Revolution. ",
"Protestant and Jewish religions were illegal in France before 1879. ",
};
int counter = 0;
public JFacts() {
// Write your code here
}
public static void main(String[] args) {
JFacts rFrame = new JFacts();
rFrame.setSize(440, 100);
rFrame.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
// Write your code here
}
}
Step by Step Solution
3.37 Rating (153 Votes )
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started