Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8596069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:35:22+00:00 2026-06-12T00:35:22+00:00

I am having issues figuring out why I’m getting a nullpointerexception thrown. It doesn’t

  • 0

I am having issues figuring out why I’m getting a nullpointerexception thrown. It doesn’t really affect anything (I don’t think at least) since everything still gets painted out properly, but I don’t like error messages.

As you can see, paint() calls this.game.paint(g2). To try to debug, everything in this.game.print has been commented out – the function does nothing so it shouldn’t be a part of the problem.

public class Application extends JFrame {

private Game game;///<stores the rules for the game and facilitates interactions

public Application() throws RoyException {
    this.game = new Game(this, 2);
}


//   @Override
public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    try{
    this.game.paint(g2);
    }catch(Exception e)
    {
        System.out.println("CAUGHT " + e.getMessage());
        e.printStackTrace();
    }
}

public static void main(String[] args) {
    try {
        Application app = new Application();
    } catch (RoyException e) {
        System.out.println("An error occurred while running the program: " + e.getMessage());
        System.out.print("Stack trace: ");
        e.getStackTrace();
    }
}

}

And here’s the stacktrace – Application.java:153 is this.game.paint(g2);

CAUGHT null java.lang.NullPointerException
    at bullshitakemushrooms.Application.paint(Application.java:153)
   Game created.
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:781)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:728)
    at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:677)
    at javax.swing.RepaintManager.access$700(RepaintManager.java:59)
    at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1621)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:701)
    at java.awt.EventQueue.access$000(EventQueue.java:102)
    at java.awt.EventQueue$3.run(EventQueue.java:662)
    at java.awt.EventQueue$3.run(EventQueue.java:660)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:671)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:35:23+00:00Added an answer on June 12, 2026 at 12:35 am

    Apparently it is a bad idea to set the window’s iconimage after setting visibility/size.

    After moving this line

    this.app.setIconImage(new ImageIcon("mushy.jpg").getImage());
    

    before

        this.app.setSize(this.maxX, this.maxY);
        this.mmenu.setVisible(true);
        app.setVisible(true);
        app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        app.setAlwaysOnTop(true);
    

    the nullpointerexception throw stopped. Lesson learned: set window icon first.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to Tomcat and I'm having some issues figuring out how to
I am having issues figuring out if this is possible. Any pointers would be
I am having issues figuring out how to sort a large data set into
I'm having issues figuring out how to programmatically upload synonyms to the google search
I'm having a really hard time figuring out the scoping issue with the following
I am having issues figuring out what this issue is. I have googled around
I seem to be having problems figuring out why the heck I keep getting
I am having issues figuring out how to do this. This isnt the real
I am having issues figuring out how to split on multiple delimiters using regular
I'm having issues figuring out where it's grabbing the default value. I tried changing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.