aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes getActionCommand() not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "getActionCommand() not working" Watch "getActionCommand() not working" New topic
Author

getActionCommand() not working

Joel Christophel
Ranch Hand

Joined: Apr 20, 2011
Posts: 241
    
    1

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

Joined: Aug 08, 2012
Posts: 2
use
code like
button.addActionListener(InstanceOfActionListener);

then button will work on click.
Joel Christophel
Ranch Hand

Joined: Apr 20, 2011
Posts: 241
    
    1

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

Joined: Jun 09, 2003
Posts: 4632
> 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

Joined: Oct 13, 2005
Posts: 40064
    
  28
I think this discussion would fit better in our GUIs forum. Moving.
Joel Christophel
Ranch Hand

Joined: Apr 20, 2011
Posts: 241
    
    1

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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getActionCommand() not working