ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 12 May 2017 My Price 9.00

public class myJButton extends JButton

myJbutton

import java.awt.*;

import javax.swing.*;

 

public class myJButton extends JButton

{

                public myJButton(String text)

                {

                                super(text);

                                setBackground(Color.red);

                                setOpaque(true);

                }

}

My java frame 6

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();

//------------------------------------------------------

// Choose a Layout for JFrame and

// add Jpanel to JFrame according to layout        

                                getContentPane().setLayout(new BorderLayout());

                                getContentPane().add(p6, "Center");

//------------------------------------------------------

                                setDefaultCloseOperation(EXIT_ON_CLOSE);

                                setSize (550, 400);

                                setVisible(true);

                }

//-------------------------------------------------------------------

}

 

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

 

myJpanel panel6

 

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

class student

{

                //---------Declaring attributes----

                String firstName;

                String lastName;

                int age;

                String status;

                //------------------------------

               

               

                //----------Constrcutor------------

                public student(String a, String b, int c)

                {

                                firstName = a;

                                lastName = b;

                                age = c;

                                if(age<) status = "Traditional";

                                else status = "Non-Traditional";

                }

               

                //---------------------------------

               

               

               

               

                //---------- METHODS --------

               

               

                String getName()

                {

                                return("NAME = "+firstName+ "  "+lastName + ", Age = "+age+", Status = "+status);

                }

               

                int getAge()

                {

                                return age;

                }

 

                String getStatus()

                {

                                return status;

                }

               

                String WhatIsUp()

                {

                                String b = "dunno";

                                double r = Math.random();

                                int myNumber = (int)(r*3f);

                                if (myNumber == 0) b = "reading";

                                if (myNumber == 1) b = "talking";

                                if (myNumber == 2) b = "interacting";

                                return b;

                }

                //--------------------------------------------

}

myJbutton

import java.awt.*;

import javax.swing.*;

 

public class myJButton extends JButton

{

                public myJButton(String text)

                {

                                super(text);

                                setBackground(Color.red);

                                setOpaque(true);

                }

}

App 6

public class  app6

{

  public static void main(String args[])

  {

    myJFrame6 mjf = new myJFrame6();

  }

}

Based on the files available here (Links to an external site.) or on the Angel folder Lab6 (app6.java, myJFrame6.java, myJPanel6.java, student.java)

An example of how to add images to buttons is available here (Links to an external site.).

 

Create a solution that tracks the use of the button #1 (student’s name)

Every time a user clicks on the first button (the button with the student’s name), you show a different what’sUp.

do it in 2 parts

Just show the what's up as a text

Just show the what's up as a text

 

myJbutonimport java.awt.*;import javax.swing.*;public class myJBuTon extends JBuTon{public myJBuTon(String text){super(text);setBackground(Color.red);setOpaque(true);}}My java frame 6import 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 J±extFieldp6 = new myJPanel6();//------------------------------------------------------// Choose a Layout for JFrame and

Attachments:

Answers

(11)
Status NEW Posted 12 May 2017 06:05 AM My Price 9.00

-----------

Attachments

file 1494572029-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)