Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to listen toolbar buttons?

 
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And what is the problem? It works!
 
arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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");
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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());
 
reply
    Bookmark Topic Watch Topic
  • New Topic