-4

Please see the error of this program in the image
It is in java swing
blog: solvedprograms.blogspot.com
thanks
anuj

Please see the error of this program in the image
It is in java swing
blog: solvedprograms.blogspot.com
thanks
anuj

import java.applet.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.*;
import java.io.*;
import java.lang.*;

public class d1 implements ActionListener
{
JButton jb;
JFrame jf;

d1()
{
button();
frame();
jf.setVisible(true);

}

public void button()
{
jb=new JButton("p2222222");
jf.add(jb,BorderLayout.EAST);
jb.addActionListener(this);
}


public void frame()
{
jf=new JFrame("p2 frame");
jf.setSize(500,500);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getActionCommand().equals(jb.getText()))
{

}
}

public static void main(String args[])throws IOException
{
SwingUtilities.invokeLater(
new Runnable()
{
    public void run()
    {
    d1 a=new d1();
    }
}
                 ); 

}

}

enter image description here

DCarochoC
  • 76
  • 8
  • 2
    Stack Overflow is not a debugging service, so please don't treat it as one. – JonK Jun 03 '14 at 13:38
  • so we have to look in every post of your blog to find out where you hide the image? – jhamon Jun 03 '14 at 13:39
  • Welcome to Stack Overflow! Unfortunately this is not a good question; to get a positive response here, please show us what you have tried to solve it yourself. Please read the [help section](http://stackoverflow.com/help/how-to-ask) or Jon Skeets famous article ["Writing the perfect question"](http://msmvps.com/blogs/jon_skeet/archive/2010/08/29/writing-the-perfect-question.aspx). These will help you create good questions that are received well. Good luck! – S.L. Barth Jun 03 '14 at 13:42

1 Answers1

1

jf (your frame) is null. you call button() before you call frame()

Moh-Aw
  • 2,836
  • 2
  • 26
  • 43