package graficos;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MasColores extends JFrame {
private JButton changeColorButton;
private Color color = Color.LIGHT_GRAY;
private Container container;
//set up GUI constructor
public MasColores()
{
super("Usando JColorChoose");
container=getContentPane();
container.setLayout(new FlowLayout());
//set up BotonCambiaColor y registro del evento
changeColorButton.addActionListener
(
new ActionListener()
{//anonymous inner class
//display JColorChooser When user clicks button
public void actionPerformed(ActionEvent event)
{
color = JColorChooser.showDialog(
MasColores.this,"Elige un color",color);
//set default color, if no color is returned
if(color==null)
color=Color.LIGHT_GRAY;
//change content pane's background color
container.setBackground(color);
}
}
);
container.add(changeColorButton);
setSize(400,130);
setVisible(true);
}
public static void main(String[] args) {
MasColores application = new MasColores();
//application.setVisible(true);
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
el error que me tira es el siguiente:
Exception in thread "main" java.lang.NullPointerException at graficos.MasColores.(MasColores.java:19) at graficos.MasColores.main(MasColores.java:40)