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

  Significant questions software installed by cable personnel

Interesting post on the computer discussion site (Slashdot) raises some significant questions about software installed by cable personnel.

  Write down macro definitions for adding and subtracting

Write down macro definitions for adding and subtracting two arguments.

  How might an information system administrator make a case

How might an information system administrator make a case for the implementation of Enterprise

  What would you recommend to meet your company needs

Your company wants to implement a strategy for backing up network data. It wants a strategy that allows it to back up changed files on a daily basis and recover lost files quickly in the event of disk failure. What would you recommend to meet your..

  Optional functionality: allow the user to print the report

A company hires you to write a program to track hourly employee arrival and departure times from work. In essence, you are tasked to make an online time clock

  Write a function prototype for a function

Write a complete function called calcTriArea that will calculate and return the area of a triangle. It takes two float/double values: the base and height as its arguments. The area of a triangle is one-half the base times the height.

  Apply yen''s algorithm to find the shortest path from node 1

Apply Yen's alogithm to find the shortest paqth from node 1 to all

  Recursive multiplication

Recursive Multiplication Write a main program that uses a recursive function. This function accepts two arguments into the parameters x and y.

  Use map to define convert-euro converts list of us dollars

Use map to define the following functions: convert-euro, which converts a list of U.S. dollar amounts into a list of euro amounts based on an exchange rate of 1.22 euro for each dollar.

  What is the position of the first character in a string

1. What is the position of the first character in a string? 2. Which C++ function(s) return(s) the number of characters currently in a string? 3. Is the data type string part of the C++ language? 4. How many parameters does the substr function hav..

  Create a pseudocode that reads in temperature input

Create a pseudocode that reads in temperature input. It should print "Freezing cold!" if the temperature is 32 degrees or below.

  Advantages of the database approach

What are the advantages of the database approach over the traditional approach to database management? What is a data center, and why are they becoming increasingly important

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