Results 1 to 2 of 2
Thread: JLabel .setActionCommand
- 03-28-2008, 03:30 AM #1Member
- Join Date
- Feb 2008
- Rep Power
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)?
- 03-28-2008, 05:16 AM #2
- By Jononomous in forum New To JavaReplies: 0Last Post: 04-07-2008, 07:41 PM
- By geork in forum New To JavaReplies: 2Last Post: 02-03-2008, 09:40 PM
- By michcio in forum New To JavaReplies: 5Last Post: 11-20-2007, 08:44 AM
- By Jack in forum AWT / SwingReplies: 2Last Post: 07-02-2007, 01:55 PM
- By Freddie in forum AWT / SwingReplies: 2Last Post: 05-29-2007, 02:19 PM