• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to listen toolbar buttons?

 
arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am amking the following simple file and lost in listening the toolbar buttons..I was trying to have common actionlistener..can you please help me..
regards,
Arun
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what is the problem? It works!
 
arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works only when it listens the File Drop down menu but fails to listen when I am clicking at the icon of the toolbar..perhaps as toolbar is not extended with the AbstractButton class..
Any solution for it...

regards
Arun
 
Angela Lamb
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your listener class is choosing the action based on the action command of the button, but you never set this property for the toolbar buttons. Add these lines to your addToolbarButtons method and it will work:
jbutton.setActionCommand("Change User/Login");
jbutton.setActionCommand("Disconnect");
 
Mula Liu
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The upstair give the correctly solution and you also can set the JToolBar Button's Mode the same with JMenuBar Button.
using the fllowing command:
JToolBarButton.setModle(JMenuBarButton.getModle());
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!