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

Could you please help me finish this application: II. PART 2: IMPLEMENT AS AN AP

ID: 3565854 • Letter: C

Question

Could you please help me finish this application:

II. PART 2: IMPLEMENT AS AN APPLICATION

Open a new file named Project3.java

A. the global declarations

1) Write the application, Project3, as a child of JFrame; it will implement ActionListener and MouseListener

2) You will need the following global declarations for the interface:

            final int variables startx and starty initialized to 100 and 150 respectively, and grdszX set to 185 and a grdiszY set to 165 (for example:    private final int startx = 80; // startx is a variable whose value is constant; any attempt to change it in your code results in an compiler error)

            Other int variables: mousex, mousey, row, col and others as needed by your code

3) You will need the following JPanels:

            northP

            southP

            eastP

4) You will need the following widgets for the northP:

            JLabels: one to contain the title

            JButton: one to start a new game or guess again

5) You will need the following widgets for southP

            JButton: to appear if the user wants to place an order

                       

6) You will need 2 to 3 Font objects to change sizes of the text you display. These are set up as follows:

private Font f = new Font("Serif",Font.BOLD, 30);              //and used as follows (when desired)

g.setFont(f);

titleLabel.setFont(f);

           

7) You will need the following One Dimensional arrays which you can copy and paste into your code to save time:

            String[] logos = {"pistons.jpg","redwings.jpg","tigers.jpg","lions.jpg", "state.jpg", "UM.jpg"};

            String[] names = {"Pistons","Redwings","Tigers","Lions","Spartans","Wolverines"};

            String[]costs = {"$15.00-$50.00", "$40.00-$150.00", "$10.00-$100.00", "$60.00-$250.00", "$12.00-$40.00", "$14.00-$80.00"};

            String [] souvenir = {"Thunderstix","mini-stick","foam-paw","paper-bag","tee-shirt","cap"};

8) You will need a one dimensional arrays of ImageIcons to store the icons of the team

                        private ImageIcon [] logo1IconArray = new ImageIcon[6];

9) You will need the following 2 dimensional array

            A two dimensional array of TeamData objects; 2 rows, 3 columns

                        private TeamData [][] teamarray = new TeamData[2][3]; //also called board or grid or table

C. The init method(or JFrame constructor in an application) will set up the interface

(use BorderLayout)

1)create the three JPanels and set their layout manager to GridLayout as follows:

northP = new JPanel();

northP.setLayout(new GridLayout(2,1)); //2 rows, 1 column

NOTE: also set up the south and east allow default flow layout

     2) create the title label and add to the northP   np.add(name of the title label);

          Do the same for the two points JButton. Remember to change font for a nice interface

3)create and add to the southP one JButton with "Click to place order" on its face

4)register the north JButton objects with the ActionListener

5)write an internal anonymous handler for the south JButton

6)add all JPanels to the contentPane as follows

c.add(northP, BorderLayout.NORTH);     //similar for south panel

      6)   register this frame with the MouseListener:   or write an internal named MouseHandler

             this.addMouseListener(this);                      this.addMouseListener(mhand);

      7) fill the ImageIcon array with the icon names):

                for (int p = 0; p<teamNames.length;p++)

                                    logo1IconArray[p]= new ImageIcon(logos[p]);

D. Write a dummy actionPerformed

     public void ActionPerformed(ActionEvent e)

      {

            g = getGraphics();

      }

E. Write dummy mouse event handlers (need all 5) //use only the MouseListener, not MouseMotionListener

F. Close the application with a close curly brace

G. Save, compile, execute: debug until you see the interface

My version (not finished):

Project 3 Part 2.

public class Project3 extends JFrame

{

private final int startX = 100;

private final int startY = 150;

private final int gradesxX = 185;

private final int grdszY = 165;

private int mousex;

private int mousey;

private int row;

private int col;

private Font f;

private JPanel northP;

private JPanel southP;

private JPanel eastP;

private JLabel titleLabel;

private JButton startButton;

private JButton orderButton;

private String[] logos = {"pistons.jpg","redwings.jpg","tigers.jpg","lions.jpg", "state.jpg", "UM.jpg"};

private String[] names = {"Pistons","Redwings","Tigers","Lions","Spartans","Wolverines"};

private String[]costs = {"$15.00-$50.00", "$40.00-$150.00", "$10.00-$100.00", "$60.00-$250.00", "$12.00-$40.00", "$14.00-$80.00"};

private String [] souvenir = {"Thunderstix","mini-stick","foam-paw","paper-bag","tee-shirt","cap"};

private Font f = new Font("Serif, Font.BOLD, 30);

private ImageIcon[] logoIconArray = new ImageIcon[6];

private TeamData[][] teamArray = new TeamData[2][1].

}

public Project3()

{

northP = new JPanel();

northP.setLayout( new GridLayout(2, 1);

southP = new JPanel();

southP.setLayout( new GridLayout(2, 1);

eastP = new JPanel();

eastP.setLayout( new GridLayout(2, 1);

northP.add(labelTitleLabel();

Start a new game or guess again = new Button (" Start a new game or guess again"(;

Do you want place an order? = new Button("Do you want place an order?");

northP.add(titleLabel);

northP.add(startLabel);

southP.add(orderButton);

c.add(northP, BorderLayout.NORTH);

c.add(southP, BorderLayout.SOUTH);

c.add(northP, BorderLayout.EAST);

Explanation / Answer

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.*;

class TeamData {}


public class Project3 extends JFrame implements ActionListener, MouseListener
{
private final int startX = 100;
private final int startY = 150;
private final int gradesxX = 185;
private final int grdszY = 165;
private int mousex;
private int mousey;
private int row;
private int col;

private JPanel northP;
private JPanel southP;
private JPanel eastP;
private JLabel titleLabel;
private JButton startButton;
private JButton orderButton;
  
private String[] logos = {"pistons.jpg","redwings.jpg","tigers.jpg","lions.jpg", "state.jpg", "UM.jpg"};
private String[] names = {"Pistons","Redwings","Tigers","Lions","Spartans","Wolverines"};
private String[]costs = {"$15.00-$50.00", "$40.00-$150.00", "$10.00-$100.00", "$60.00-$250.00", "$12.00-$40.00", "$14.00-$80.00"};
private String [] souvenir = {"Thunderstix","mini-stick","foam-paw","paper-bag","tee-shirt","cap"};
  
private Font f = new Font("Serif", Font.BOLD, 30);
private ImageIcon[] logoIconArray = new ImageIcon[6];
  
private TeamData[][] teamArray = new TeamData[2][3];


public Project3()
{
Container c = this.getContentPane();
c.setLayout(new BorderLayout());
northP = new JPanel();
  
northP.setLayout( new GridLayout(2, 1));
  
southP = new JPanel();
southP.setLayout( new GridLayout(2, 1));
  
eastP = new JPanel();
eastP.setLayout( new GridLayout(2, 1));
  
titleLabel = new JLabel("Project3");

startButton = new JButton (" Start a new game or guess again");
  
orderButton = new JButton("Do you want place an order?");
  
northP.add(titleLabel);
northP.add(startButton);
  
southP.add(orderButton);
  
c.add(northP, BorderLayout.NORTH);
c.add(southP, BorderLayout.SOUTH);
this.addMouseListener(this);
  
startButton.addActionListener(this);
orderButton.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {
placeOrder();
  
}
});
  
for (int p = 0; p<names.length;p++)
logoIconArray[p]= new ImageIcon(logos[p]);
}


private void placeOrder() {
// TODO Auto-generated method stub
  
}


@Override
public void mouseClicked(MouseEvent e)
{
// TODO Auto-generated method stub
  
}


@Override
public void mousePressed(MouseEvent e)
{
// TODO Auto-generated method stub
  
}


@Override
public void mouseReleased(MouseEvent e)
{
// TODO Auto-generated method stub
  
}


@Override
public void mouseEntered(MouseEvent e)
{
// TODO Auto-generated method stub
  
}


@Override
public void mouseExited(MouseEvent e)
{
// TODO Auto-generated method stub
  
}


@Override
public void actionPerformed(ActionEvent e)
{
// TODO Auto-generated method stub
  
}
  
  
public static void main(String[] args)
{
Project3 proj = new Project3();
proj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
proj.setSize(500, 500);
proj.setVisible(true);
  
}
}