app6.java public class app6 { public static void main(String args[]) { myJFrame6 mjf = new myJFrame6(); } } myJButton.java import java.awt.*; import javax.swing.*; public class
app6.java
public class app6 { public static void main(String args[]) { myJFrame6 mjf = new myJFrame6(); } } myJButton.java
import java.awt.*; import javax.swing.*;
public class myJButton extends JButton { public myJButton(String text) { super(text); setBackground(Color.red); setOpaque(true); } }
myJFrame6.java
import java.awt.*; import javax.swing.*; import java.awt.event.*;
public class myJFrame6 extends JFrame { myJPanel6 p6; public myJFrame6 () { super ("My First Frame");
JTextField p6 = new myJPanel6();
getContentPane().setLayout(new BorderLayout()); getContentPane().add(p6, "Center");
setDefaultCloseOperation(EXIT_ON_CLOSE); setSize (550, 400); setVisible(true); }
}
myJPanel6.java
import java.awt.*; import javax.swing.*; import java.awt.event.*;
public class myJPanel6 extends JPanel { myJButton b1,b2; public myJPanel6() { setLayout(new GridLayout(1,1));
student st1 = new student("Michael", "Robinson", 20);
b1 = new myJButton(st1.getName()); add(b1);
b2 = new myJButton(st1.WhatIsUp()); add(b2); } }
student.java
public class Student extends Person{ String status; String Major;
Student(String informedFirstName, String informedLastName, int informedAge) { super(informedFirstName, informedLastName, informedAge); if (informedAge
String whatIsUp() { int n = 0; String b = "..."; n = (int) (Math.random() * 3); if (n == 0) { b = "Attending class"; } if (n == 1) { b = "Doing homework"; } if (n == 2) { b = "Surfing the web";
} return b; } String getStatus() { return status; }
String getInfo() { return ("Name = " + getName() + ", age =" + getAge() + ", Status = "+getStatus()+ ", Major= "+getMajor()); }
} class Person{ String informedFirstNam; String informedLastName; int informedAge; public Person(String informedFirstName, String informedLastName, int informedAge) { this.informedFirstNam=informedFirstName; this.informedLastName=informedLastName; this.informedAge=informedAge; } String getName() { return(this.informedFirstNam+" "+this.informedLastName); } int getAge() { return(this.informedAge); } }
If you can complete the assignment without the provided code that will work. Thanks
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started