The Artima Developer Community
Sponsored Link

Java Answers Forum
Please! urgent help needed with a grid!!

1 reply on 1 page. Most recent reply: Mar 22, 2003 12:51 PM by Rich Burgis

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Pete

Posts: 1
Nickname: petewh
Registered: Mar, 2003

Please! urgent help needed with a grid!! Posted: Mar 22, 2003 10:11 AM
Reply to this message Reply
Advertisement
Hi, I really need someone's help.

I need to create a grid of cells, and have access to each cell on the 'board'. How do I go about creating a grid? I understand 2D arrays may be involved, but I want to be able to see the grid lines of this grid. I do not think a JTable will be suitable, since, ultimately, a simulation will be needed to run on the board.

Thanks for any help at all you can give me.

Cheers


Rich Burgis

Posts: 17
Nickname: songbird
Registered: Mar, 2003

Re: Please! urgent help needed with a grid!! Posted: Mar 22, 2003 12:51 PM
Reply to this message Reply
I've had good luck with using a plain canvas and drawing the grid then drawing the contents of the cell that I keep in a 2 dimensional array.

I have a drawGrid function that I call from the paint method as

private void drawGrid( Graphics _g )
{
for( int idx = 0; idx < rowCount; idx++ )
_g.drawLine( left, idx * rowHeight, right, idx * rowHeight )

for( int idx = 0; idx < colCount; idx++ )
_g.drawLie( idx * colWidth, top, idx * colWidth, bottom )
}

Flat View: This topic has 1 reply on 1 page
Topic: Basic Java Programmin help Previous Topic   Next Topic Topic: How to get obj address / actual reference value?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use