Could you please help me with this assignment below, the PSUCOde for this assign
ID: 3842524 • Letter: C
Question
Could you please help me with this assignment below, the PSUCOde for this assignment that in the picture 1.
Use IdleGameStartingTemplatejava and MouseClickingAndMouseEnteringAndLeaving.java to get the clicking feature built into your java file. Then, use the Button Maker.txt to copy and paste and insert in 5 buttons into your code. The location of the buttons should match the locations in your pseudo code or at least where you want them to be. Each time you click on a button, have a counter show up on the screen via a g drawstring with outputting the count of the times the button was pressed. This should look something like this below Button 1 pressed 10 times Button pressed 2 times Button 3 pressed 5634 times Button 4 pressed 1 times Button 5 pressed 550 times However, the locations of everything is up to you. Remember, the default font height is 10 so you can set it up in a list easily by just increasing your y value by 10 each time. Buttons can just be g.fillRect to make it easy, we will change this into an image later (if you want). Please realize, you can turn in your code at this point if you want to track your progress, Otherwise, you will get credit when you have 5 working buttons in a later version of the program (this is what prefer, less grading for me).Explanation / Answer
I tried my best to get the solution to the above but in applet it is difficult to do. Below is the code which might help you.
//ButtonViewer.java
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class ButtonViewer
{
private static final int FRAME_WIDTH = 250;
private static final int FRAME_HEIGHT = 250;
public static void main(String[] args)
{
JFrame frame = new JFrame();
JPanel panel = new JPanel();
JButton button1 = new JButton("Click me!");
panel.add(button1);
JButton button2 = new JButton("Click me!");
panel.add(button2);
JButton button3 = new JButton("Click me!");
panel.add(button3);
JButton button4 = new JButton("Click me!");
panel.add(button4);
JButton button5 = new JButton("Click me!");
panel.add(button5);
frame.add(panel);
ActionListener listener = new ClickListener();
button1.addActionListener(listener);
ActionListener listener2 = new ClickListener();
button2.addActionListener(listener2);
ActionListener listener3 = new ClickListener();
button3.addActionListener(listener3);
ActionListener listener4 = new ClickListener();
button4.addActionListener(listener4);
ActionListener listener5 = new ClickListener();
button5.addActionListener(listener5);
frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
//ClickListener.java
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ClickListener implements ActionListener
{
private int numClicks = 0;
public void actionPerformed(ActionEvent event)
{
numClicks++;
System.out.println("I was clicked " + numClicks + " times.");
}
}