Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

Deliverables app.java, myJFrame.java, myJPanel.java, and other necessary Java files Contents:

Deliverables

app.java, myJFrame.java, myJPanel.java, and other necessary Java files

Contents:

The objective of the lab is to create game in which the player has to click on a moving student-button to score.

The student button has to move constantly (using the timer)

The application has to keep the score

The actual score has to be shown.

Implement at least one of the extras listed below (3 to 7)

Suggested steps:

Get the student button moving

You need the get timer started

You need a null layout (check the layout Java examples)

You need to set a different position for the button every time the timer ticks

Keep the score on a separate button, every click on the student button increases the score by 1.

When these two things are working, change the image of the student button when it is clicked.

When 3 is implemented, add a slider to make the button move faster or slower.

You need to use the setDelay() method applied to the timer

When 4 is implemented, make the movement smooth instead of jumping from one place to another place very far away.

Make the student-button run faster when the mouse approaches it.

When 5 and 6 are implemented, then do whatever else you want to add to it.

app.java

public class app

{

public static void main(String args[])

{

   myJFrame mjf = new myJFrame();

}

}

myJFrame.java

import java.awt.*;

import javax.swing.*;

public class myJFrame extends JFrame

{

  myJPanelstd mjp;

  public myJFrame ()

  {

     super ("My First Frame");

//------------------------------------------------------

// Create components

     mjp = new myJPanelstd();

//------------------------------------------------------

// Choose a Layout for JFrame and

// add Jpanel to JFrame according to layout     

     getContentPane().setLayout(new BorderLayout());

     getContentPane().add(mjp,"Center");

//------------------------------------------------------

     setDefaultCloseOperation(EXIT_ON_CLOSE);

     setSize (640, 480);

     setVisible(true);

  }

}

myJPanelstd.java

import java.awt.*;

import javax.swing.*;

public class myJPanelstd extends JPanel

{

  public myJPanelstd()

  {

           super();

           setBackground(Color.pink);

      JButton jb1;

       jb1 = new JButton("a real student-button should be here, not me, a simple JButton ...");

//-------------------------------------------------------     

// add buttons to JPanel     

//-------------------------------------------------------     

     add(jb1);

  }

}

student.java

import java.awt.*;

import javax.swing.*;

public class student

{

     String firstName;

     String lastName;

     int age;

     public student(String a, String b, int x)

     {  

        super();

        firstName = a;

        lastName = b;

        age = x;

     }

     String getInfo()

     {

        return "NAME = "+firstName+ " "+lastName+" "+"Age = "+age;

     }

}

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question