Create a jframe that uses borderlayout

Assignment Help Basic Computer Science
Reference no: EM13306236

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

}

}

 

Reference no: EM13306236

Questions Cloud

Write a program and create a flow chart : The game of Nim. This is a well-known game with a number of variants. We will consider the following variants, which has an interesting winning strategy. Two players alternately take marbles from a pile.
How are adc used in medical devices : How are ADC's used in medical devices? Please give examples
Create a list containing the union of the elements : Create a list containing the union of the elements of the two lists? Insert an element after the nth element of the list.?
Battleship redux : Game Battleship is back and better than ever. Instead of hacking everything together in C, you will instead leverage C++ and all of your newly gained object oriented programming knowledge to construct a much cleaner end product.
Create a jframe that uses borderlayout : 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.
Determine the length of the strings of this instrument : Your friend recently purchased a musical instrument that generates sound waves using several strings. Determine the length of the strings of this instrument
Determine aerodynamic drag on the full-scale prototyple car : The aerodynamic drag of a new sports car is to be predicted at a speed of 50mph at an air temperature of 25 degrees Celcius. Automotive engineers build a one-fifth scale model of the car to test in a wind tunnel.
Calculate the minimum required wall thickness t-min : A tubular aluminium bar (G=28GPa) of square cross section with outer dimensions 50mm x 50mm must resist a torque T=300Nm. Calculate the minimum required wall thickness t_min if allowbale shear stress is 20MPa
Discuss and share rich and diverse assortment of reference : Discuss and share the rich and diverse assortment of reference sources for the Bourne Again Shell (BASH).

Reviews

Write a Review

 

Basic Computer Science Questions & Answers

  Encode audio data in two packets

How might you encode audio (or video) data in two packets so that if one packet is lost, then resolution is simply decreased to what would be expected with half bandwidth?

  Write a program that calculates and prints the product

Write a program that calculates and prints the product of the odd integers from 1 to 15. Do this using while loop, for loop, and do-while loop.

  Write a method firstlast that could be added

Write a method firstLast that could be added to the LinkedIntList class that moves the first element of the list to the back end of the list. Suppose a LinkedIntList variable named list stores the following elements from front (left) to back (right)

  Showing how to use the html element

Describe the attributes that you think would be useful with the HTML element. Provide an example code snippet showing how to use the HTML element. !DocType Html

  Most important components of a fully specified enterprise

What are the two most important components of a fully specified enterprise model? Describe the two basic approaches to designing an enterprise model.

  Elements corresponding to the inorder sequence

Suppose that you are given two sequences of elements corresponding to the inorder sequence and the preorder sequence. Prove that it is possible to reconstruct a unique binary tree .

  Case study discussing network forensics

Research by finding an article or case study discussing network forensics

  Evaluate for risk management purposes

Choose three information assets that a typical organization has and evaluate for risk management purposes which vulnerability should be evaluated for additional controls first?

  What is uml

What is UML? What does a + or - signify

  How it sales manager learn technical in his role

How does an IT sales manager learn to be technical in his role without over complicating the IT aspects most consumers want to understand

  Logical data-base structure

A report generator is used to. Which of the following is not a logical data-base structure?

  Describe a situation where dynamic memory allocation

Describe a situation where dynamic memory allocation might be required in order to make efficient use of your computer's resources. Also describe the precautions that your program should take for the correct and efficient implementation of dynamic..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd