Question: Deliverables: app.java myJFrame.java myJPanel.java and other necessary Java files Contents The objective of the lab is to create a game in which the player has

Deliverables:

app.java

myJFrame.java

myJPanel.java

and other necessary Java files

Contents

The objective of the lab is to create a 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)

Level of difficulty: High

Level of usefulness for the final project: Very High

EXTRAS:

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;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!