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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:52:38+00:00 2026-05-26T05:52:38+00:00

This is quite odd, because I have a Character class that can access Frame.dimension.getWidth();

  • 0

This is quite odd, because I have a Character class that can access Frame.dimension.getWidth(); and its partner getHeight(), however when I wanted to use this in the Map class eclipse underlines it and cannot give me feedback. Running the program anyways ends up in java errors stating they can’t find the X value of a Map object.

Here’s the Frame class:

package Core;

import java.awt.Dimension;
import java.awt.Rectangle;
import javax.swing.JFrame;


public class Frame
{
static int width = 800, height = 600;
static Dimension dimension;

public static void main(String[]args){
    JFrame frame= new JFrame("RETRO");
    frame.add(new Screen());

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(width,height);
    frame.setVisible(true);
    frame.setResizable(false);
    dimension = frame.getContentPane().getSize();
}
}

And the Map class:

package Core;

import java.awt.Frame;
import java.awt.Image;
import java.awt.Rectangle;
import javax.swing.ImageIcon;
import java.awt.Dimension;

public class Map
{
    double x, y;

Image map;
ImageIcon background = new ImageIcon("images/Maps/maze.jpg");

public Map(){
    map = background.getImage();
}

public void move(double moveX, double moveY){
        x += moveX;
        y += moveY;
}

//////////Gets
public Image getMap(){
    return map;
}
public double getX(){
    if(x<0)
        x=0;
    else if(x>Frame.dimension.getWidth())
        x=Frame.dimension.getWidth();

    return x;
}

public double getY(){
    if(y<0)
        y=0;
    else if(y>Frame.dimension.getHeight())
        y=Frame.dimension.getHeight();

    return y;
}

public int getHeight(){
    return map.getHeight(null);
}

public int getWidth(){
    return map.getWidth(null);
}
}

I could provide the Character class but it is very long and messy at the moment.. however the word Frame was only used in the calling of Frame.dimension.getWidth()/getHeight();

  • 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-05-26T05:52:38+00:00Added an answer on May 26, 2026 at 5:52 am

    the Frame class you refer to in x=Frame.dimension.getWidth(); is java.awt.Frame. note that you imported this class. Try mentioning explicitly: Core.Frame instead or remove the line import java.awt.Frame; if you don’t use this class.

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

Sidebar

Related Questions

This is quite odd, but I have a script that was until now calling
I have this quite popular problem, but have failed to find a solution that
I have a very odd issue trying to run this quite simple C program
This will be probable quite odd question. But i thought I will give it
This question is perhaps somehow odd, but how can I speed up g++ compile
I'm trying to (cross-)compile node.js and I get this odd error that appears to
Quite simple, I'm learning Python, and I can't find a reference that tells me
I have come across a very odd problem in C that I have never
To begin, I must say that I have searched for quite a long time
Getting some odd behaviour in a Perl script that I don't quite understand. I'm

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.