Please help me fix the errors in the java program below import javax.swing.*; import java.awt.event.*; import java.awt.*; public class Halloween extends JFrame implements ActionListener { int hallo[][] = { { 4, 6, 2 }, { 1, 4, 3 }, { 3, 5, 2 }, { 2, 3, 5 }, { 4, 1, 3 } }; int rows = 3; int cols = 5; JButton pics[] = new JButton[rows * cols]; public Halloween() { setSize(600, 600); JPanel grid = new JPanel(new GridLayout(rows, cols)); int m = 0; for (int x = 0; x < rows; x++) { for (int y = 0; y < cols; y++) { pics[m] = new JButton(createImageIcon("back.png")); pics[m].addActionListener(this); pics[m].setActionCommand(m + ""); pics[m].setPreferredSize(new Dimension(100, 100)); grid.add(pics[m]); m++; } } add(grid); setVisible(true); } public void actionPerformed(ActionEvent ae) {}if(e.getActionCommand().equals("Reset")) { for (int m = 0; m < pics.length; m++) pics[m].setIcon(createImageIcon("back.png")); }else { int n = Integer.parseInt(e.getActionCommand()); int x = n % rows; int y = n / rows; pics[n].setIcon(createImageIcon("hal" + hallo[x][y] + ".png")); } } protected static ImageIcon createImageIcon(String path) { java.net.URL imgURL = Halloween.class.getResource(path); if (imgURL != null) { return new ImageIcon(imgURL); } else { System.err.println("Couldn't find file: " + path); return null; } } }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Please help me fix the errors in the java program below import javax.swing.*; import java.awt.event.*; import java.awt.*; public class Halloween extends JFrame implements ActionListener { int hallo[][] = { { 4, 6, 2 }, { 1, 4, 3 }, { 3, 5, 2 }, { 2, 3, 5 }, { 4, 1, 3 } }; int rows = 3; int cols = 5; JButton pics[] = new JButton[rows * cols]; public Halloween() { setSize(600, 600); JPanel grid = new JPanel(new GridLayout(rows, cols)); int m = 0; for (int x = 0; x < rows; x++) { for (int y = 0; y < cols; y++) { pics[m] = new JButton(createImageIcon("back.png")); pics[m].addActionListener(this); pics[m].setActionCommand(m + ""); pics[m].setPreferredSize(new Dimension(100, 100)); grid.add(pics[m]); m++; } } add(grid); setVisible(true); } public void actionPerformed(ActionEvent ae) {}if(e.getActionCommand().equals("Reset")) { for (int m = 0; m < pics.length; m++) pics[m].setIcon(createImageIcon("back.png")); }else { int n = Integer.parseInt(e.getActionCommand()); int x = n % rows; int y = n / rows; pics[n].setIcon(createImageIcon("hal" + hallo[x][y] + ".png")); } } protected static ImageIcon createImageIcon(String path) { java.net.URL imgURL = Halloween.class.getResource(path); if (imgURL != null) { return new ImageIcon(imgURL); } else { System.err.println("Couldn't find file: " + path); return null; } } }
Halloween Matching
1. Add the array to make these pictures.
2. Add a reset button. Change its font and color. Its action Command must be "Reset
3. Add a title. Change its font.
back.png hall.png hal2.png hal3.png hal4.png hal5.png
hal6.png
Transcribed Image Text:Halloween Matching 1. Add the array to make these pictures. 2. Add a reset button. Change its font and color. Its action Command must be "Reset 3. Add a title. Change its font. back.png hall.png hal2.png hal3.png hal4.png hal5.png hal6.png
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY