Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Create a JFrame that uses BorderLayout. Place a JButton in the center region. Each time the user clicks the JButton, change the background color in one of the other regions. Save the file as JColorFrame.java.

 

Okay, So I wrote the program in netbeans and I didn't get any errors during the build. But when I compile and run the program from the terminal nothing happens. Is there somethind I'm doing wrong?

 

/*import java.awt.*;

 

import java.awt.event.*;

 

 

public class JColorFrame extends Frame implements ActionListener

 

{

 

Button colorButton = new Button("Change");

 

Panel cp = new Panel();

 

Panel np = new Panel();

 

Panel sp = new Panel();

 

Panel ep = new Panel();

 

Panel wp = new Panel();

 

int count = 0;

 

public JColorFrame()

 

{

 

super("Colors");

 

setLayout(new BorderLayout());

 

cp.add(colorButton);

 

add(np, "North");

 

add(sp, "South");

 

add(ep, "East");

 

add(wp, "West");

 

add(cp, "Center");

 

colorButton.addActionListener(this);

 

}

 

public void actionPerformed(ActionEvent e)

 

{

 

if(count%5==0)

 

np.setBackground(Color.green);

 

else if(count%5==1)

 

ep.setBackground(Color.magenta);

 

else if(count%5==2)

 

wp.setBackground(Color.orange);

 

else if(count%5==3)

 

sp.setBackground(Color.red);

 

else

 

{

 

ep.setBackground(Color.white);

 

sp.setBackground(Color.white);

 

np.setBackground(Color.white);

 

wp.setBackground(Color.white);

 

}

 

 

++count;

 

}

 

}

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/

 

/**

*

* @author SeriousOrangutan

*/

public class JColorFrame {

 

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

}

}

 

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9885557

Have any Question?


Related Questions in Computer Engineering

Question whats the roles of user roles and why are they

Question : What's the roles of user roles and why are they necessary for Linux? How are these roles and permission similar and different from other types of users and other operating systems?

Question need a discussion post of 500-700 words in apa

Question: Need a discussion post of 500-700 words in APA format with 4 references & citations. Only For Dr. Silvercoast Which of these principles can you apply at your workplace? Select one or two and provide examples. O ...

Suppose users share a 3 mbps link also suppose each user

Suppose users share a 3 Mbps link. Also suppose each user requires 150 kbps when transmitting, but each user transmits only 10 percent of the time. When circuit switching is used, how many users can be supported? For the ...

Penetration testing is a technique used to identify

Penetration testing is a technique used to identify security weaknesses in your network. Discuss a type of penetration testing and the different methods utilized to recognize vulnerabilities in your network.

Information systemsdirections answer the following if you

Information Systems Directions : Answer the following: If you were asked to develop a logical model of the registration system at a school, would it be better to use a top-down or bottom-up approach? Explain your reasoni ...

Recall that a floating-point number can be expressed as-1s

Recall that a floating-point number can be expressed as (-1) s (1 + f) 2 e where s, f and e are binary numbers. Recall that s is the sign indicator, f the mantissa (or fractional part), and e the exponent. Suppose the si ...

Question summary of what is legal and regulatory

Question : Summary of what is legal and regulatory obligations regarding data and information security. Summary of project initiation in the technology world.

A researcher thinks that listening to classical music

A researcher thinks that listening to classical music reduces anxiety. She measures the anxiety of 10 persons then plays Mozart's "Eine Kleine Nachtmusik". Following that the researcher measures their anxiety again. (Not ...

Question you must use the following outline for your paper

Question: You MUST use the following outline for your paper. All direct and indirect quotes should be properly cited using APA formatting. All sections should be labeled. This week's paper is a final draft. All spelling, ...

Question specify design implement im c a class for a card

Question : Specify, design implement im c++ a class for a card in a deck of playing cards. The object should contain methods for setting and retrieving the suit and rank of the card. Make sure to separate your work on s ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As