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
}
}