Java - Excepcion Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

 
Vista:
sin imagen de perfil

Excepcion Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

Publicado por Maria Augusta (1 intervención) el 17/02/2016 22:58:25
Buenas tardes
me podrian ayudar con este programa me sale esttos errores

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Flor.actionPerformed(Flor.java:100)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)





el programa es ::::



import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Polygon;
import java.applet.Applet;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.border.EmptyBorder;
import java.lang.Thread;


public class Flor extends JFrame implements ActionListener {

JPanel ContenidoPane;
JButton Girar, Parar,Prueba;
Graphics g;
ActionEvent ex;

int vx1 [] = {300,325,350,300,250,275};
int vy1 [] = {200,225,100,50,100,225};

int vx2 [] = {375,375,500,525,450,350};
int vy2 [] = {225,250,200,125,100,225};

int vx3 [] = {400,375,500,550,500,375};
int vy3 [] = {300,325,350,300,250,275};

int vx4 [] = {375,350,450,525,500,375};
int vy4 [] = {375,375,500,475,400,350};

int vx5 [] = {300,275,250,300,350,325};
int vy5 [] = {400,375,500,550,500,375};

int vx6 [] = {225,225,100,75,150,250};
int vy6 [] = {375,350,400,475,500,375};

int vx7 [] = {200,225,100,50,100,225};
int vy7 [] = {300,275,250,300,350,325};

int vx8 [] = {225,250,150,75,100,225};
int vy8 [] = {225,225,100,125,200,250};

public Flor (){

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(600,600,600,600);
ContenidoPane = new JPanel();
ContenidoPane.setBorder(new EmptyBorder(5,5,5,5));
setContentPane(ContenidoPane);
ContenidoPane.setLayout(null);
setBounds(0,0,600,600);

setLayout (null);
Girar = new JButton (" GIRAR ");
Girar.setBounds(50,500,100,50);
add(Girar);
Girar.addActionListener (this);

Parar = new JButton (" PARAR ");
Parar.setBounds(50,10,100,50);
add(Parar);
Parar.addActionListener (this);
}//fin constructor

public void paint(Graphics g)
{

super.paint(g);
g.setColor(Color.black);
g.drawOval(250,250,100,100);


g.drawPolygon(vx1, vy1, 6);
g.drawPolygon(vx2, vy2, 6);
g.drawPolygon(vx3, vy3, 6);
g.drawPolygon(vx4, vy4, 6);
g.drawPolygon(vx5, vy5, 6);
g.drawPolygon(vx6, vy6, 6);
g.drawPolygon(vx7, vy7, 6);
g.drawPolygon(vx8, vy8, 6);


}

public void actionPerformed (ActionEvent ex)
{

//Object BotonSeleccionado = ex.getSource();//del evento q genera se captura con Source para cargar en objeto general y ver que se hizo

if(ex.getSource() == this.Girar)
{

for(int i=1;i<=8;i++)
{

if(i==1)

{
g.setColor(Color.BLUE);
g.fillPolygon(vx1, vy1, 6);
if(ex.getSource()== this.Parar)
break;
}
if(i==2)

{ g.setColor(Color.blue);
g.drawPolygon(vx1, vy1, 6);
g.fillPolygon(vx2, vy2, 6);
if(ex.getSource() == this.Parar)
break;
}
if(i==3)

{ g.setColor(Color.blue);
g.drawPolygon(vx1, vy1, 6);
g.drawPolygon(vx2, vy2, 6);
g.fillPolygon(vx3, vy3, 6);
if(ex.getSource()== this.Parar)
break;
}
if(i==4)

{ g.setColor(Color.blue);
g.drawPolygon(vx1, vy1, 6);
g.drawPolygon(vx2, vy2, 6);
g.drawPolygon(vx3, vy3, 6);
g.fillPolygon(vx4, vy4, 6);
if(ex.getSource()== this.Parar)
break;
}
if(i==5)

{ g.setColor(Color.blue);
g.drawPolygon(vx1, vy1, 6);
g.drawPolygon(vx2, vy2, 6);
g.drawPolygon(vx3, vy3, 6);
g.drawPolygon(vx4, vy4, 6);
g.fillPolygon(vx5, vy5, 6);
if(ex.getSource() == this.Parar)
break;
}
if(i==6)

{ g.setColor(Color.blue);
g.drawPolygon(vx1, vy1, 6);
g.drawPolygon(vx2, vy2, 6);
g.drawPolygon(vx3, vy3, 6);
g.drawPolygon(vx4, vy4, 6);
g.drawPolygon(vx5, vy5, 6);
g.fillPolygon(vx6, vy6, 6);
if(ex.getSource()== this.Parar)
break;
}
if(i==7)

{ g.setColor(Color.blue);
g.drawPolygon(vx1, vy1, 6);
g.drawPolygon(vx2, vy2, 6);
g.drawPolygon(vx3, vy3, 6);
g.drawPolygon(vx4, vy4, 6);
g.drawPolygon(vx5, vy5, 6);
g.drawPolygon(vx6, vy6, 6);
g.fillPolygon(vx7, vy7, 6);
if(ex.getSource() == this.Parar)
break;
}

if(i==8)

{ g.setColor(Color.blue);
g.drawPolygon(vx1, vy1, 6);
g.drawPolygon(vx2, vy2, 6);
g.drawPolygon(vx3, vy3, 6);
g.drawPolygon(vx4, vy4, 6);
g.drawPolygon(vx5, vy5, 6);
g.drawPolygon(vx6, vy6, 6);
g.drawPolygon(vx7, vy7, 6);
g.fillPolygon(vx8, vy8, 6);
if(ex.getSource() == this.Parar)
break;
}

}
};


}//fin escuchador






public static void main (String [] args) {
Flor Ven = new Flor();
Ven.setVisible(true);
}//fin del main



}


Les agradecería mucho su ayuda
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Excepcion Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

Publicado por arck (145 intervenciones) el 18/02/2016 11:50:02
Como no se si se pasa en las mismas lineas
Si están Bien mírate la linea 100

g.setColor(Color.BLUE);
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar