I've listed all of the errors in the program and identified where they are. I've been working on this all morning, but i can't figure our how to fix the remaining errors. Can you please help me to find a solution to finish the program, also, can you add edit or improve anything within the program itself.
import java.util.Scanner;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class DannysJeopardy2 extends JFrame implements ActionListener { /***Line 7 Error*/
int width = 800;
int height = 800;
int score;
JLabel methods = new JLabel("Methods");
JButton methods1 = new JButton("$100");
JButton methods2 = new JButton ("$200");
JButton methods3 = new JButton ("$300");
JButton methods4 = new JButton("$500");
JLabel strings = new JLabel("Strings");
JButton strings1 = new JButton("$100");
JButton strings2 = new JButton("$200");
JButton strings3 = new JButton("$300");
JButton strings4 = new JButton("$500");
JLabel conditional = new JLabel("Conditional Control Structures");
JButton conditional1 = new JButton("$100");
JButton conditional2 = new JButton("$200");
JButton conditional3 = new JButton("$300");
JButton conditional4 = new JButton("$500");
JLabel loops = new JLabel("Loops");
JButton loops1 = new JButton("$100");
JButton loops2 = new JButton("$200");
JButton loops3 = new JButton("$300");
JButton loops4 = new JButton("$500");
JButton bRestart = new JButton("Restart");
public DannysJeopardy2(){
super("Jeopardy!");
this.setVisible(true);
this.setSize(width, height);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static void main (String[] args) { /***Line 44 error*/
public void actions (Object source) {
int tScore;
int score;
String guess;
if (source == methods1)
{ methods1(); }
if (source == strings1)
{ strings1(); }
if (source == conditional1)
{ conditional1(); }
if (source == loops1)
{ loops1(); }
if (source == methods2)
{ methods2(); }
if (source == strings2)
{ strings2(); }
if (source == conditional2)
{ conditional2(); }
if (source == loops2)
{ loops2(); }
if (source == methods3)
{ methods3(); }
if (source == strings3)
{ strings3(); }
if (source == conditional3)
{ conditional3(); }
if (source == loops3)
{ loops3(); }
if (source == methods4)
{ methods4(); }
if (source == strings4)
{ strings4(); }
if (source == conditional4)
{ conditional4(); }
if (source == loops4)
{ loops4(); }
methods1.setEnabled(true);
strings1.setEnabled(true);
conditional1.setEnabled(true);
loops1.setEnabled(true);
methods2.setEnabled(true);
strings2.setEnabled(true);
conditional2.setEnabled(true);
loops2.setEnabled(true);
methods3.setEnabled(true);
strings3.setEnabled(true);
conditional3.setEnabled(true);
loops3.setEnabled(true);
methods4.setEnabled(true);
strings4.setEnabled(true);
conditional4.setEnabled(true);
loops4.setEnabled(true);
score = 0;
tScore.setText(score + "");
}
DannysJeopardy2 myWorld = new DannysJeopardy2();
public void output(String s){
JFrame rw = new JFrame("Are you right or wrong?");
rw.setVisible(true);
rw.setSize(200, 100);
rw.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
rw.setAlwaysOnTop(true);
JButton brw = new JButton(s);
rw.getContentPane().add(brw);
try
{
Thread.sleep(1000);
}
catch(Exception e){};
rw.dispose();
}
public String inputString(String quest){
JFrame what = new JFrame("What is your Guess?");
what.setVisible(true);
what.setSize(400, 200);
what.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
what.setAlwaysOnTop(true);
JTextField question = new JTextField(quest);
JTextField guess = new JTextField(50);
Container x = what.getContentPane();
x.setLayout(new FlowLayout());
x.add(question);
x.add(guess);
JButton enter = new JButton("Enter");
x.add(enter);
enter.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
return guess.getText(); /*** Line 148 Error*/
}
});
}
5 errors found:
File: F:\Computer Science\DannysJeopardy2.java [line: 7]
Error: The type DannysJeopardy2 must implement the inherited abstract method java.awt.event.ActionListener.actionPerformed(java .awt.event.ActionEvent)
File: F:\Computer Science\DannysJeopardy2.java [line: 44]
Error: Syntax error, insert "}" to complete MethodBody
File: F:\Computer Science\DannysJeopardy2.java [line: 109]
Error: Cannot invoke setText(java.lang.String) on the primitive type int
File: F:\Computer Science\DannysJeopardy2.java [line: 148]
Error: Void methods cannot return a value
File: F:\Computer Science\DannysJeopardy2.java [line: 148]
Error: Cannot refer to a non-final variable guess inside an inner class defined in a different method