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
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...
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");
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());