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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:40:38+00:00 2026-05-23T07:40:38+00:00

Trying to make a Grid Like this using java and I’m assuming a 2d

  • 0

Trying to make a Grid Like this using java and I’m assuming a 2d Array, I’m eventually going to be making this into checkers game. Making a grid is quite easy but what I am wondering is how can I visually represent this array, so for example the top row second from the left square would be like [0][2] make each square correspond an array index. Any advice would be great, I finished the first java class and I know that this is the first project we get for the next class So! im trying to figure it out, thanks for any help!

  • 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-23T07:40:39+00:00Added an answer on May 23, 2026 at 7:40 am

    Given that it’s an internal convention, it is entirely up to you: simply pick one of the corners of the grid e.g. top-lef, as your origin. (General convention is to use top-left as origin and bottom-right as [x-max][y-max].)

    Your model can be anything from a single dimensional raster model or a 2d array, or even nested Lists. Choice of model entirely depends on the use-case and performance requirements. For your case — introductory homework — 2d array is a straightforward and sensible choice.

    For drawing to a grid cell @ (i,j), you’ll need a method to get the canvas coordinates (x,y) of a given grid cell:

    /** maps grid cell to coordinates of cell */
    public Point getCoordinates(int i, int j);
    

    Here you have a couple of choices: should you return the center point e.g. the middle point of a black square, or its relative origin e.g. its top-left coordinates? Depends on what you are trying to do. For example, if you are going to be rendering little icons at each cell, the paint api takes the top-left coordinate of the image you are rendering, so in that case, returning the origin is sensible.

    You also need to decide if you need to map from a point in the visual grid to your data. For example, user clicks in the canvas and you need to determine the corresponding data cell. (You probably don’t need this)

    /** maps point in canvas to a data cell - returned 'point' is (i, j) */
    public Point getIndex (int x, int y);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make something that looks like this, but I don't know how
Trying to make a MySQL-based application support MS SQL, I ran into the following
I am trying to make a div, that when you click it turns into
I am trying to make an Outlook 2003 add-in using Visual Studio 2008 on
I'm trying to make a mouse over for a stack panel in WPF using
I have been trying to get yui-css grid system to make a three column
I am trying to make a Facebook Client and I have XAML file like
I am trying to build a grid, using class info and its properties along
Trying to make a make generic select control that I can dynamically add elements
Trying to make a generic PL/SQL procedure to export data in specific XML format,

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.