Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating a NxN grid.

 
El Durango
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 9279
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
El Durango
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the links.
I found out both JLabels and JButtons can accomplish what I need.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic