• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getActionCommand() not working

 
Joel Christophel
Ranch Hand
Posts: 250
1
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I have a grid of buttons all triggering events when clicked on (via ActionListener), but when I try to print out getActionCommand(), nothing happens. Also, how do I get rid of the annoying box being placed around the icon of the button most recently clicked. There's a picture of it below.

 
Ramesh P Prasad
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use
code like
button.addActionListener(InstanceOfActionListener);

then button will work on click.
 
Joel Christophel
Ranch Hand
Posts: 250
1
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramesh P Prasad wrote:use
code like
button.addActionListener(InstanceOfActionListener);

then button will work on click.


That's precisely what I did...
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> but when I try to print out getActionCommand(), nothing happens.

getActionCommand() will return the button's text - there appears to be no text,
so you would have to use setActionCommand(...) when you create the buttons

> Also, how do I get rid of the annoying box being placed around the icon of the button most recently clicked.

looks like the focus indicator, so include this line when creating the buttons
button.setFocusPainted(false);
 
Campbell Ritchie
Sheriff
Pie
Posts: 49849
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this discussion would fit better in our GUIs forum. Moving.
 
Joel Christophel
Ranch Hand
Posts: 250
1
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael Dunn wrote:

getActionCommand() will return the button's text - there appears to be no text,
so you would have to use setActionCommand(...) when you create the buttons

looks like the focus indicator, so include this line when creating the buttons
button.setFocusPainted(false);


Thanks! Everything worked like a charm!
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic