Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at academia.TAcolor.JBnegroActionPerformed(TAcolor.ja va:74)
at academia.TAcolor.access$000(TAcolor.java:13)
at academia.TAcolor$1.actionPerformed(TAcolor.java:50 )
at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.jav a:6535)
at javax.swing.JComponent.processMouseEvent(JComponen t.java:3324)
at java.awt.Component.processEvent(Component.java:630 0)
at java.awt.Container.processEvent(Container.java:223 6)
at java.awt.Component.dispatchEventImpl(Component.jav a:4891)
at java.awt.Container.dispatchEventImpl(Container.jav a:2294)
at java.awt.Component.dispatchEvent(Component.java:47 13)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4888)
at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4525)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4466)
at java.awt.Container.dispatchEventImpl(Container.jav a:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2750 )
at java.awt.Component.dispatchEvent(Component.java:47 13)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessI mpl.doIntersectionPrivilege(ProtectionDomain.java: 76)
at java.security.ProtectionDomain$JavaSecurityAccessI mpl.doIntersectionPrivilege(ProtectionDomain.java: 86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessI mpl.doIntersectionPrivilege(ProtectionDomain.java: 76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 728)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:82)
Código:
El error creo que es básicamente en como hago referencia a la ventana donde se encuentra el JTextArea desde la que tiene los 3 botones que no se exactamente como hacerlo o si lo estoy haciendo bien si quiera. package academia; import java.awt.Color; import java.awt.*; /** * * @author UNI */ public class TAcolor extends javax.swing.JFrame { /** * Creates new form TAcolor */ public TAcolor(RegistroAlumnos reg){ this(); this.reg=reg; } private TAcolor() { initComponents(); } private void JBnegroActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: if (JBnegro==evt.getSource()){ } } private void JBgrisActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: reg.setColorFondo(java.awt.Color.GRAY); } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new TAcolor().setVisible(true); } }); } private RegistroAlumnos reg; // Variables declaration - do not modify private javax.swing.JButton JBazul; private javax.swing.JButton JBgris; private javax.swing.JButton JBnegro; // End of variables declaration }