• Post Reply Bookmark Topic Watch Topic
  • New Topic

adding actionlistener to jmenu

 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im trying to add an actionlistener to a jmenu i.e Print however I cannot get it to work

jMenu_Print.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{

I know it works for jmenuitems. Also if I create a jmenu with no menu items when you click on it you see something as if its an empty item below it how can I get rid of this

Thank you very much for your time
[ May 25, 2005: Message edited by: john mattucci ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't plan on having any items under the Print then just use a JMenuItem, not a JMenu.



FYI - I'd probably just put something like this on a JToolBar rather than a JMenuBar. It's more common for menu's to drop down with options and JToolBar to contain duplicates of the common actions from the JMenuBar.
[ May 25, 2005: Message edited by: Gregg Bolinger ]
 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
one problem when I add simply the jmenuitem it pushes all other jmenus and it becomes rather large
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by john mattucci:
one problem when I add simply the jmenuitem it pushes all other jmenus and it becomes rather large


Hmm, I didn't think about that. Well, then use a JToolBar. There's a reason Menus and ToolBars are 2 different things. They provide 2 different services although providing the same outcome.
 
Humans and their filthy friendship brings nothing but trouble. My only solace is this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!