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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:37:48+00:00 2026-06-07T19:37:48+00:00

so im making a simple box from java and this is the code so

  • 0

so im making a simple box from java and this is the code so far:

import java.awt.Canvas;
import javax.swing.JFrame;

public class Display {

    public static final int WIDTH = 800;
    public static final int LENGTH = 600;

    public static void main(String[] args) {
        Display game = new Display();
        JFrame frame = new JFrame();
        frame.setResizable(false);
        frame.setVisible(true);
        frame.setSize(WIDTH, LENGTH);
        frame.add(game);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}

im getting an error here “frame.add(game);” its says “The method add(Component) in the type Container is not applicable for the arguments (Display)”

How im not sure what im doing wrong, im using javaSE-1.6

  • 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-07T19:37:50+00:00Added an answer on June 7, 2026 at 7:37 pm

    You’re trying to add an instance of Display, which isn’t a Swing component, to your frame, hence the error. Looking at your imports, you probably meant to add a JPanel within your Display class (if there is one) to the frame.

    Alternatively, your Display class needs to inherit from something like JComponent, if you want to add it directly. You shouldn’t mix AWT and Swing components needlessly.

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

Sidebar

Related Questions

I'm making a simple URL request with code like this: URL url = new
I'm making a simple app using the HTML5 <canvas> tag and compile the code
I'm making a simple control based on a TScrollingWinControl (and code copied from a
I'm making a simple mediaplayer app that downloads a song from a predetermined URL
I was reviewing a code from a simple PONG game code in c#, the
I am making a simple chat box control. Its just a hobby project to
I am making a simple app that reads data in from a file. So
I'm making a simple program that takes text entered in a text box, and
I am making a simple snippet that should pass a Box[String] with the requests
I am making simple grid like game ( grid is matrix 128x128) and matrix

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.