[java] Clicking on canvases... (canvii?)

Started by
0 comments, last by Smoo 24 years, 1 month ago
Hello again folks. Well I''m at it again with yet another problem. Basically what I have is a Panel with 4 canvases and 4 labels underneath each canvas (it''s to scroll through the tiles for a game editor). So what I want to do is when I click on a canvas, I want the label underneath it to go a different background color. Well it''s the clicking that''s the problem. Here''s what I tried: public boolean action (Event evt, Object arg) { String lbl = new String(); for (int x = 0; x < 4; x++) { if (evt.target == canvas[x]) lblObj[x].setBackground(Color.blue); else lblObj[x].setBackground(Color.lightGray); } return true; } Well needless to say this didn''t work. Does anyone have any other ideas/suggestions? I''d appreciate it. Thanks. Smoo BTW canvas[x] is another class that extends canvas
Advertisement
I believe this is using the old event model in Java...I highly recommend changing to using an ActionListener and updating the label in actionPerformed.

This topic is closed to new replies.

Advertisement