Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Swing / AWT / SWT and the fly likes Creating a NxN grid. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Creating a NxN grid." Watch "Creating a NxN grid." New topic

Creating a NxN grid.

El Durango

Joined: Oct 09, 2003
Posts: 23
Hello I am new to Java AWT/Swing and have a question.
I would like to create a 10x10 grid, where each "cell" can handle mouse
events. So if I click on cell with a coord A4 then it would change color.
I was thinking of using JButtons but I want the "cells" to look more like
Excel-like in appearance. Any suggestions?? I want the end result to produce a look of a rubix cube and when clicking a cell it changes to a random color. Can JButtons accomplish this look??
Joe Ess

Joined: Oct 29, 2001
Posts: 9168

Originally posted by El Durango:
Can JButtons accomplish this look??

They can look like anything you want them to look like. Consult the
Custom Painting trail of the Swing Tutorial. However, for your purposes, you could probably acheive an excel-like gui by using JLabels and setting a boarder on them. The Swing Tutorial can help you with that too.

[How To Ask Questions On JavaRanch]
El Durango

Joined: Oct 09, 2003
Posts: 23
Thanks for the links.
I found out both JLabels and JButtons can accomplish what I need.
I agree. Here's the link:
subject: Creating a NxN grid.
It's not a secret anymore!