Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

My program is giving me 4 errors. If anyone can just tell me how to fix the erro

ID: 3535521 • Letter: M

Question

My program is giving me 4 errors. If anyone can just tell me how to fix the errors.


import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class MyNamerProg7 extends JFrame

{

private static final int WIDTH = 350;

private static final int HEIGHT = 350;

private JLabel color = new JLabel ("Enter Color");

private JTextField colorName = new JTextField(6);

private String colors[] = {"Red", "White", "Yellow", "Green", "Blue"};

public MyNameProg7()

{

setTitle("Memory Game");

setSize(WIDTH, HEIGHT);

setLayout(new FlowLayout());

setDefaultCloseOperation(EXIT_ON_CLOSE);

String dialogBox = "";

for (int i = 0; i < 5; i++)

{

dialogBox = colors[i] + " ";

}

JOptionPane.showMessageDialog(null, "How good is your memory?" +

" Try to memorize this color sequence:" +

" Red White Yellow Green Blue");

}

private class TextFieldHandler implements ActionListener

{

public void actionPerformed(ActionEvent a)

{

String color = colorName.getText();

if (color.isEmpty())

{

if (color < 5)

{

color.setText("Enter Color");

colorName.setText("");

}

else

{

colors.setText("Sorry- wrong color, Eat more antioxidants.");

}

}

else

{

colors.setText("Congratulations- your memory is perfect!");

}

}

}

public static void main(String args[])

{

JFrame frame = new MyNameProg7();

frame.setVisible(true);

frame.setDefaultCloseOperation(3);

}

}





Explanation / Answer

1) error in public class MyNamerProg7()

solution :public class MyNameProg7

2) colors.setText

solution color.setText

3)String color = colorName.getText();

solution : String colortxt = colorName.getText();

4)color < 5

solution : colortxt.length()<5


Dr Jack
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote