Code: app.java public class app { public static void main(String args[]) { myJFr
ID: 3675020 • Letter: C
Question
Code:
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");
mjp = new myJPanelstd();
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;
}
}
Disregard the part about writing a paragraph i'll handle that. Basically just do what the second part of instructions says, I want the student (student.java) to act graphically. After you make the changes to the original student.java class, you should be able to use statements that are normally used with a regular JButton.
For instance:
student st1 = new student
add(st1);
st1.setBackgound(Color.blue);
As always Thanks
Deliverables - a paragraph explaining why this is useful for the final project ap.jirna, "n, Riane.jinna, "ry. R%ael.jinna, Niluk.jana write a paragraph explaining why it would be useful for the final project to have a student (or any other creature) being a JButton Explain how is it possible to be done Implement an example in Java I want the student (student.java) to act graphically. After you make the changes to the original student.java class, you should be able For instance: . add(st1); ·st 1. setBackgound(Color-blue);Explanation / Answer
put this code inside of the Student.java class then execute it you i'll get.
String student_JButt()
{
double n = Math.random();
int my_No = (int) (n * 3f);
String solution =" I do not know. " ;
if(my_No == 0) solution =" searching the web. " ;
if(my_No == 1) solution =" doing Java. " ;
if(my_No == 2) solution =" Listening 2 endless lecture. " ;
return solution;
}