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

The challenge I?m having is communicating with different classes. I have a stude

ID: 642984 • Letter: T

Question

The challenge I?m having is communicating with different classes. I have a student created in myJPanel1.java and I cannot create another student; one this one object in the whole application and display info about the student in another panel? I need to change two lines in the code of myJPanel, create appropriate tracking for the button in myJPanel1 and Create a way to let the second panel (myJPanel2) to ?learn? about the student and display the graphics which will change to display the whatsUp every time the user clicks on the student button on the first panel. And I cannot make any changes to myJPanel2. Here is my work thus far and below my work is my output

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

public class myJPanel extends JPanel
{
   public myJPanel()
   {
       super();
       setBackground(Color.gray);
      
       setLayout(new BorderLayout());

       myJPanel1 p1 = new myJPanel1();
       myJPanel2 p2 = new myJPanel2();

      
       add(p1,"North");
       add(p2,"Center");
      
          
      
   }
}

------------------------------------------------------------

//Create tracking for JButton

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

public class myJPanel1 extends JPanel
{
   JButton b1;
   public myJPanel1()
   {
       super();
       setBackground(Color.yellow);
       b1 = new JButton("student info will be here later ...");
       add(b1);
       }
      
}

----------------------------------------------------------------------------------------------

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

public class myJPanel2 extends JPanel
{
   JButton b2;
   student st1;
   public myJPanel2()
   {
       super();
       st1 = new student("Fred","Fonseca",44);
       setBackground(Color.pink);
       b2 = new JButton("whats Up will be shown here" );
       add(b2);
      
   }
  
}

---------------------------------------------------------------------

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;
       }
  
  
  
       String whatsUp()
       {
           double r = Math.random();
           int myNumber = (int) (r * 3f); //comment: a random number between 0 and 2
           String answer = "I don't know";
           if(myNumber == 0) answer = "searching the web";
           if(myNumber == 1) answer = "doing Java";
           if(myNumber == 2) answer = "Listening to endless lecture";
           return answer;
         

}

------------------------------

Explanation / Answer

app.java

myJFrame.java

myJPanel.java

myJPanel1.java

myJPanel2.java

myJPanelHelp.java

myJPanelPlay.java

myJPanelScores.java

myJPanelWelcome.java

myJTabbedPane.java

Student.java

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote