Deliverables
app.java, myJFrame.java, myJPanel.java and student.java as
requested below.
(Use the student.java class that you already have from previous
labs)
Contents
Based on the graphics you learned this week
Create an instance (an object, i.e., st1) of student in
myJPanel
Display his/her basic information
Display for 10 times what he/she is up to (using the method
whatIsUp() that your student class already has)

--------------------------------------------------------------------------------------------------
\\app.java
public class app
{
public static void main(String args[])
{
myJFrame mjf = new myJFrame();
}
}
-----------------------------------------------------------------------------
\\myJFrame.java
import java.awt.*;
import javax.swing.*;
import static javax.swing.JFrame.EXIT_ON_CLOSE;
public class myJFrame extends JFrame
{
public myJFrame ()
{
super ("My First Frame");
myJPanel mjp = new myJPanel();
getContentPane().add(mjp,"Center");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize (800, 480);
setVisible(true);
}
}
-------------------------------------------------------------------------------
\\myJPanel.java
import java.awt.*;
import javax.swing.*;
public class myJPanel extends JPanel
{
public myJPanel ()
{
super ();
GridLayout grid = new GridLayout(1,1);
setLayout(grid);
setBackground(Color.green);
PanelLeft left = new PanelLeft();
PanelRight right = new PanelRight();
add(left);
add(right);
//BorderLayout border = new BorderLayout();
//setLayout(border);
//setBackground(Color.pink);
//JButton jb1 = new JButton("Hello");
//jb1.setBackground(Color.WHITE);
//JButton jb2 = new JButton(" Goodbye");
//jb2.setBackground(Color.yellow);
//JButton jb3 = new JButton("I am a JButton");
//jb3.setBackground(Color.CYAN);
//add(jb1,"North");
//add(jb2,"Center");
//add(jb3,"South");
}
}
--------------------------------------------------------------------------------
\\student.java
//student is a person with a status ("traditional" or
"non-traditional")
//Displays all the info (and "status" reusing class person) about
them in the most efficient way possible (avoid unnecessary
duplication)
class student extends person
{
String status;
public student(String informedFirstName, String
informedLastName, int informedAge)
{
super(informedFirstName,
informedLastName, informedAge);
if (age <= 25) status =
"Traditional";
else status =
"Non-Traditional";
}
public String whatIsUp()
{
int n = 0;
String b = "...";
n = (int) (Math.random()*2);
if (n == 0) b = "reading";
if (n == 1) b = "talking";
return b;
}
String getStatus()
{
return status;
}
//void display()
//{
public String getInfo()
{
return super.getInfo()+"\nStatus: "+getStatus()+"\nState:
"+whatIsUp();
}
//System.out.println("---------------------");
//System.out.println("Student Information");
//System.out.println(getInfo()+ "Status: " + getStatus());
//System.out.println();
//}
}
//app.java
public class app
{
public static void main(String args[])
{
//Instantiate the myJFrame
myJFrame mjf = new
myJFrame();
}
}
----------------------------------------------------------------------------------------
//myJFrame.java
import java.awt.*;
import javax.swing.*;
public class myJFrame extends JFrame
{
//Declare panel variable
private JPanel studentPanel;
//set width and height of the frame
private final int APPLICATION_WIDTH=450;
private final int APPLICATION_HEIGHT=350;
private static JButton name=new JButton();
public myJFrame ()
{
super ("My First Frame");
//Call the method
createStudentPanel that adds the student info
//to the panel add to the
frame
createStudentPanel();
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(APPLICATION_WIDTH,
APPLICATION_HEIGHT);
setVisible(true);
}
public void createStudentPanel()
{
//Create myJPanel
studentPanel = new
myJPanel();
//Create an instance of student
class
student std1=new
student("Fred","Fonseca", 45);
//set layout flow layout
studentPanel.setLayout(new
FlowLayout());
//create a JButton for name and
age
JButton nameage=new
JButton(std1.getNameAge());
//add name and age
studentPanel.add(nameage);
//call getinfo on std1 object and
add
//the name info to the studentPanel
10 times
for (int index = 0; index < 10;
index++)
{
JButton
status=new JButton(std1.whatIsUp());
studentPanel.add(status);
}
//add student panel to the
frame
add(studentPanel);
}
}
------------------------------------------------------------------------------------------------
//myJPanel.java
import java.awt.*;
import javax.swing.*;
public class myJPanel extends JPanel
{
public myJPanel ()
{
super ();
GridLayout grid = new
GridLayout(1,1);
setLayout(grid);
setBackground(Color.pink);
}
}
----------------------------------------------------------------------
//student.java
//student is a person with a status ("traditional" or
"non-traditional")
//Displays all the info (and "status" reusing class person) about
them in the most efficient way possible (avoid unnecessary
duplication)
class student extends person
{
String status;
public student(String informedFirstName, String
informedLastName, int informedAge)
{
super(informedFirstName,
informedLastName,informedAge);
if (informedAge <= 25)
status =
"Traditional";
else
status =
"Non-Traditional";
}
public String whatIsUp()
{
int n = 0;
String b = "...";
//create three random whatisup options
n = (int) (Math.random()*3);
if (n == 0) b = "Listening to
endless lecture";
if (n == 1) b = "doing java";
if (n == 2) b = "Searching the
web";
return b;
}
String getStatus()
{
return status;
}
public String getInfo()
{
return super.getInfo()+"\nStatus:
"+getStatus()+"\nState: "+whatIsUp();
}
public String getNameAge()
{
return super.getInfo();
}
}
----------------------------------------------------------------------------------------------------
//Create a person class with first name and last name
public class person
{
private String informedFirstName;
private String informedLastName;
private int informedAge;
//constructor that sets the first name and last
name
public person(String informedFirstName, String
informedLastName,int informedAge)
{
this.informedFirstName=informedFirstName;
this.informedLastName=informedLastName;
this.informedAge=informedAge;
}
//Returns the name of the person
public String getInfo()
{
return "Name =
"+informedFirstName+" "+informedLastName+"Age ="+informedAge;
}
}
------------------------------------------------------------------------------------
Sample output:

Hope this helps you
Deliverables app.java, myJFrame.java, myJPanel.java and student.java as requested below. (Use the student.java class that you already...
Basic button tracking
Deliverables
Updated files for
app6.java
myJFrame6.java
myJPanel6.java
student.java
Contents
You can start with the files available here.
public class app6
{
public static void main(String args[])
{
myJFrame6 mjf = new myJFrame6();
}
}
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class myJFrame6 extends JFrame
{
myJPanel6 p6;
public myJFrame6 ()
{
super ("My First Frame");
//------------------------------------------------------
// Create components: Jpanel, JLabel and JTextField
p6 = new myJPanel6();
//------------------------------------------------------...
I need help in converting this into pseudo-code Student.java public class Student implements Comparable<Student>{ private String name, major, status; private int rank; public Student() { this.name = this.major = this.status = ""; this.rank = 0; } public Student(String name, String major, String status) { this.name = name; this.major = major; this.status = status; } public String getName() { return name; } public String getMajor() { return major; } public String getStatus() { return status; } public int...
Any thoughts on this, i can get it to run but can't pass code around and the button doesnt move around. i didnt pass the student, or the app.java. What will you learn Combined use of Timer and the tracking of user interactions 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...
**Using NetBeans**
Lesson
Using inheritance to reuse classes.
Deliverables
person.java
student.java
studentAthlete.java
app.java
Using inheritance and the classes (below)
The person class has
first name
last name
age
hometown
a method called getInfo() that returns all attributes from
person as a String
The student class is a person with
an id and
a major and
a GPA
student has to call super passing the parameters for
the super class constructor
a method called getInfo() that returns all attributes from
student...
The method m() of class B overrides the m() method of class A, true or false? class A int i; public void maint i) { this.is } } class B extends A{ public void m(Strings) { 1 Select one: True False For the following code, which statement is correct? public class Test { public static void main(String[] args) { Object al = new AC: Object a2 = new Object(); System.out.println(al); System.out.println(a): } } class A intx @Override public String toString()...
JAVA program Note: you can't change anything is already written Student.java public class Student { private String name; private String major; private double gpa; public Student(String name, String major, double gpa) { // TO-DO: Assign the given parameters to the data fields. Use the this keyword. } public double getGPA() { // TO-DO: return this.gpa } public String getName() { // TO-DO: return this.name }...
JAVA
3files seprate
1.Classroom.java
2.ClassroomTester.java (provided)
3.Student.java(provided)
Use the following files:
ClassroomTester.java
import java.util.ArrayList;
/**
* Write a description of class UniversityTester here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class ClassroomTester
{
public static void main(String[] args)
{
ArrayList<Double> grades1 = new ArrayList<>();
grades1.add(82.0);
grades1.add(91.5);
grades1.add(85.0);
Student student1 = new Student("Srivani", grades1);
ArrayList<Double> grades2 = new ArrayList<>();
grades2.add(95.0);
grades2.add(87.0);
grades2.add(99.0);
grades2.add(100.0);
Student student2 = new Student("Carlos", grades2);
ArrayList<Double> grades3 = new...
Can you fix my error? I created a program that changes labels every second in Java. But, it does not change. And, it will starts with second label. This is also an error. import java.awt.BorderLayout; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.Timer; public class Map2 extends JFrame{ JPanel panel; JLabel pic; Timer tm; int x = 0; String ly = "<html> " + "<br> <font size='10' color='red'> <b> 111111111 <b/> </font>...
How do I start this Java: Inheritance problem?
• person.java • student.java • studentAthlete.java • app.java • Students should apply consistent indenting in all submissions. This can be done via the NetBeans Source menu. Contents person First name Last name app Creates 1 student-athlete object Hometown Retinfo) 1-Displays the complete information about the student-athlete object student New attributes Maior attributes getinfo) method from the superlas person Student-athlete student's rankine Overrides the method from the superclass student Video from Professor Fisher...
Given a class called Student and a class called Course that
contains an ArrayList of Student. Write a method called
getDeansList() as described below. Refer to Student.java below to
learn what methods are available.
I will paste both of the simple .JAVA codes below
COURSE.JAVA
import java.util.*;
import java.io.*;
/******************************************************
* A list of students in a course
*****************************************************/
public class Course{
/** collection of Students */
private ArrayList<Student> roster;
/*****************************************************
Constructor for objects of class Course
*****************************************************/...