1 Reply Latest reply on May 18, 2006 1:34 AM by 843805

    AWT to Swing Question

      I have been trying to convert an AWT app to Swing. I started trying to convert the entire app in one shot and had this same problem. Now I have been slowly adding Swing to the App currently only in the form of JPanels. I can get jpanels to work fine, but when I try to change a Button to a Jbutton

      I get:

      Exception in thread "main" java.lang.NullPointerException
      at java.awt.Container.addImpl(Unknown Source)
      at java.awt.Container.add(Unknown Source)

      The line of code that it references is just an


      If I don't add the Jbutton everything works fine.
      And if its a AWT button it works fine.

      I figure this is something simple that I'm missing, Anyone know what up from this vague description.?
        • 1. Re: AWT to Swing Question
          It looks like "myJbutton" contains the value null. At least, that's what I'd assume.

          My second thought would be that something significant about the JButton (label, image, preferred size, etc.) had been set to null.

          Any of this sound right at all?