Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-28-2008, 03:30 AM
Member
 
Join Date: Feb 2008
Posts: 7
stevemcc is on a distinguished road
JLabel .setActionCommand
I am making a chess board. Each space is represented by a JLabel. When the user clicks the JLabel, I would like to color the squares around it with the possible moves. This is done by one of my methods that is passed the x, y position of the piece on the space clicked. I figured I would do this by setting the .setActionCommand of each of to "00", "01", "02", etc. This way before I needed to pass they x and y, I could check the .setActionCommand value for the coords. Well, apparently, JLabels do not have this method like JButtons do. I see JLabels have .setActionMap, but I dont know this method is meant to work the same as .setActionCommand.

So my question is, is there I was I can sort of 'mark' my JLabels with its coord so when it is clicked I can check it (many JLabels will use the same Listener)?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-28-2008, 05:16 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,029
hardwired is on a distinguished road
Try the Component method get/setName or the JComponent method get/setClientProperty.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
JLabel append? Jononomous New To Java 0 04-07-2008 08:41 PM
Problems with JLabel 2 geork New To Java 2 02-03-2008 09:40 PM
help me with JFrame and JLabel michcio New To Java 5 11-20-2007 08:44 AM
JLabel Jack AWT / Swing 2 07-02-2007 02:55 PM
JLabel Freddie AWT / Swing 2 05-29-2007 03:19 PM


All times are GMT +3. The time now is 01:07 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org