Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...The enviroment is simple, natural and efficient. The members are competent, educated and professionals..."

Geography

Where in the world do Tek-Tips members come from?
Ptrively (MIS)
26 Jun 04 2:40
Hello,

Recently I was going to attempt to make a type of checkers game in Java.  This is a rather "ambitious" project for me, but I felt it was with in my possibilities.  I started by creating a board, using the rect.drawRect(x, y, height, width) command, and managed through a simple loop to come up with a nice checker board.  However, I could not for the life of me figure out how to create an active listener for where the mouse lands.  

SO, I wanted to use JButtons instead, I remembered that JButtons have the SetIcon command, and assumed J++ would have an easy way to select that icon (Black Square, Black Square with piece, White Square).  However, I have not been able to figure out how to add JButtons/panels to my project, any help would be VERY appreciated.  I've searched for a few hours on this already.

Paul@trively.net
Spiny (Programmer)
11 Jul 04 9:32
You can't use JButtons unless you've got swing.  Unfortunately, due to rather acrimonious disputes between Microsoft and Sun, the only way to get swing is to download it from http://www.java.sun.com.  Odly, the latest jdk also comes without swing.  I don't quite know how to get hold of it, although I'm trying.  It comes as part of the javax package, which must be a separate download.  I'll post again if I find it.  
On the mouselistener front, use the e.getX() and e.getY() to get the position of the mouse cursor, and have an array of points which are the top left-hand corner of each square, and use this in a for loop to work out which sqsuare was hit.  
Hope this helps,
SpinyNorman

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close