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 8041461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:13:42+00:00 2026-06-05T04:13:42+00:00

So, I;m following a tutorial and I followed it exactly but when I test,

  • 0

So, I;m following a tutorial and I followed it exactly but when I test, it throws a

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code -   constructor Main in class spritesheet.Main cannot be applied to given types;
  required: java.awt.Color
  found: no arguments
  reason: actual and formal argument lists differ in length
at spritesheet.Main.main(Main.java:48)
Java Result: 1

error!

This is my code:

package spritesheet;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;

public class Main extends JFrame {

BufferedImage sprite;
  private final Color Color;

public Main(Color white){
    setSize(800, 600);
    setVisible(true);
    setResizable(true);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLocationRelativeTo(null);
    setBackground(Color=white); 
    init();
}


private void init(){
    BufferedImageLoader loader = new BufferedImageLoader();
    BufferedImage spriteSheet = null;
    try {
        spriteSheet = loader.loadImage("spritesheet.png");
    } catch (IOException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
    SpriteSheet ss = new SpriteSheet(spriteSheet);

    sprite = ss.grabSprite(0, 0, 16, 16);
}

@Override
public void paint(Graphics g){
    g.drawImage(sprite, 100, 100, null);
    repaint();

}

public static void main(String[] args) {
    Main Main = new Main();
}
}

This code aims to display a still image on a white background however it either throws an error or shows a transparent background. It then bugs out and annoys me. 🙁
What am I doing wrong????

  • 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-05T04:13:45+00:00Added an answer on June 5, 2026 at 4:13 am

    You call your class like this

    Main Main = new Main();
    

    But you need to pass a parameter to it because you defined it as

    public Main(Color white) { ... }
    

    You could change it to

    Main Main = new Main(Color.WHITE);
    

    and

    public Main(Color c) {
       setSize(800, 600);
       setVisible(true);
       setResizable(true);
       setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       setLocationRelativeTo(null);
       Color = c;
       setBackground(Color); 
       init();
    }
    

    Edit

    You can do 2 things now. Either make your Colorvariable static like this:

    private static Color Color;
    

    or change your Main constructor to

    public Main() {
       setSize(800, 600);
       setVisible(true);
       setResizable(true);
       setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       setLocationRelativeTo(null);
       Color = Color.WHITE;
       setBackground(Color); 
       init();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using java 6 annotation processing api. I have followed the following excellent tutorial
I followed this tutorial exactly and received the following error after trying to upload
i am following this simple tutorial and i followed all the steps... but the
I followed the following tutorial (although I installed Glassfish Open Source Edition, instead of
I'm following the Heroku Django tutorial . I believe I followed it exactly. I
I've followed a tutorial and came up with the following method to read the
So I followed the following tutorial on creating custom views associated with device orientations:
I've followed the following tutorial, in the simulator it works great, however on my
I followed the following tutorial to embed Maps to my application. Later on I
I need help, I followed the following tutorial on setting up my project. http://lwjgl.org/wiki/index.php?title=Setting_Up_LWJGL_with_NetBeans

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.