The Artima Developer Community
Sponsored Link

Java Answers Forum
Adding a JPopupMenu to a JMenu

1 reply on 1 page. Most recent reply: Jan 18, 2004 3:43 AM by gabri

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
tsigo

Posts: 3
Nickname: tsigo
Registered: Jan, 2004

Adding a JPopupMenu to a JMenu Posted: Jan 17, 2004 2:58 PM
Reply to this message Reply
Advertisement
How do I add a JPopupMenu to a JMenu? I've tried
<br><br>

myMenu.add(new JMenuItem().add(popupMenu));

<br><br>
and
<br><br>

myMenu.add(popupMenu);

<br><br>
But neither makes the popup menu's items show up.


gabri

Posts: 9
Nickname: gabri
Registered: Jan, 2004

Re: Adding a JPopupMenu to a JMenu Posted: Jan 18, 2004 3:43 AM
Reply to this message Reply
I faced the same problem and found an ugly way around it:

JMenuBar bar=new JMenuBar();
setJMenuBar(bar);
JMenu mainmenu=new JMenu("Documents");
JMenu addDoc=new JMenu("Add");
addDoc.add(new JMenuItem("Book"));
addDoc.add(new JMenuItem("Journal"));
addDoc.add(new JMenuItem("Article"));
mainmenu.add(addDoc);
mainmenu.add(new JMenuItem("Do smth else"));
bar.add(mainmenu);

This only solves problem but doesnt answer the question.. hope
it helps like this also..
best wishes,
gabri

Flat View: This topic has 1 reply on 1 page
Topic: RDBMS Engine and java Previous Topic   Next Topic Topic: Difference between Interface and Abstract Classes

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use