Question: I need this code to display the students name in jb1, and the display the whatisup function in the student.java code where jb2 is //app.java

I need this code to display the students name in jb1, and the display the whatisup function in the student.java code where jb2 is

//app.java public class app { //Main public static void main(String[] args) { //Create new instance MyJFrame jf = new MyJFrame(); } }

//ourJPanel.java import java.awt.*; import javax.swing.*;

//Class public class ourJPanel extends JPanel { //Constructor public ourJPanel() { //From super class super(); //Set background color as gray setBackground(Color.gray); //Set border layout setLayout(new BorderLayout()); //Create new instance ourJPanel1 jp1 = new ourJPanel1(); //Create new instance ourJPanel2 jp2 = new ourJPanel2(); //Add panel add(jp1,"North"); //Add panel add(jp2,"Center"); } }

//ourJPanel1.java import java.awt.*; import javax.swing.*; import java.awt.event.*;

//Class public class ourJPanel1 extends JPanel { //Create a new instance JButton jb1; //Constructor public ourJPanel1() { //From super class super(); //Set background color as yellow setBackground(Color.yellow); //Show jb1 = new JButton("Student information will be here..."); //Add button add(jb1); } }

//ourJPanel2.java import java.awt.*; import javax.swing.*; import java.awt.event.*;

//Class public class ourJPanel2 extends JPanel { //Create a new instance JButton jb2; //Constructor public ourJPanel2() { //From super class super(); //Set background color as pink setBackground(Color.pink); //Show jb2 = new JButton("whatsUp will be shown here" ); //Add button add(jb2); } }

//MyJFrame.java import java.awt.*; import javax.swing.*;

//Class public class MyJFrame extends JFrame { //Constructor public MyJFrame() { //Super super ("Our Frame"); //Create new instance ourJPanel ojp = new ourJPanel(); //Add frame getContentPane().add(ojp,"Center"); //Set default close on exit setDefaultCloseOperation(EXIT_ON_CLOSE); //Set size of the frame setSize (640, 480); //Set frame visibility setVisible(true); } }

student.java

class student extends person { String status; String major;

student(String informedFirstName, String informedLastName, int informedAge, String informedMajor) { super(informedFirstName, informedLastName, informedAge);

major = informedMajor;

if (age <= 25) status = "Traditional"; else status = "Non-Traditional"; }

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 ; }

String getMajor() { return major; }

}

person.java

public class person { String firstName; String lastName; int age;

person(String informedFirstName, String informedLastName, int informedAge) { firstName = informedFirstName; lastName = informedLastName; age = informedAge; }

String whatIsUp() { return "undetermined"; }

String getName() { return firstName +" "+lastName; }

String getAge() { String str = String.valueOf(age); return str; }

String getInfo() { return (getName() + " " + getAge()); }

}

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!