Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Help me java says cannot invoke javax.swing.JFrame.add(java.awt.Component) because this.frame is null

  1. #1
    Junior Member
    Join Date
    Jun 2022
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Help me java says cannot invoke javax.swing.JFrame.add(java.awt.Component) because this.frame is null

    Hi,

    I have IntelliJ and am trying to make a GUI application and it says this:
    cannot invoke javax.swing.JFrame.add(java.awt.Component) because this.frame is null
    Someone told me the JFrame thing is null, but didn't tell me how to fix.
    Please help me fix the issue.
    Thanks,
    pikachuwu

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help me java says cannot invoke javax.swing.JFrame.add(java.awt.Component) because this.frame is null

    Please post the code that has the error(wrapped in code tags). Post complete code that can be compiled to see the error.

    If a variable has a null value, the program needs to assign it a valid value.
    For example:
       JFrame myFrame;               // myFrame has a null value
       myFrame = new JFrame();  //  assign value to myFrame
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [SOLVED] both class javax.swing.Timer in javax.swing and class java.util.Timer in java.util match
    By stresstedout in forum What's Wrong With My Code?
    Replies: 13
    Last Post: April 10th, 2014, 07:32 PM
  2. What's the difference between "import.javax.swing*" and JFrame inheritance
    By Johnny Bravo in forum Object Oriented Programming
    Replies: 5
    Last Post: August 14th, 2012, 09:28 AM
  3. Java Tip Jul 29, 2010 - Swing Console Component
    By helloworld922 in forum Java Code Snippets and Tutorials
    Replies: 2
    Last Post: August 24th, 2010, 06:48 AM
  4. How to Use the JList component - Java Swing
    By neo_2010 in forum Java Swing Tutorials
    Replies: 1
    Last Post: July 11th, 2009, 04:02 AM
  5. How to Use the JList component - Java Swing
    By neo_2010 in forum Java Code Snippets and Tutorials
    Replies: 1
    Last Post: July 11th, 2009, 04:02 AM