Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / August 2007

Tip: Looking for answers? Try searching our database.

JPopUpMenu when right-clicking JMenuItem

Thread view: 
maro20081984@forislam.com - 25 Aug 2007 16:41 GMT
hi all,
i have a problem in JPopupMenu that's supposed to appear when the user
right click on a menuItem like Favorites in Internet explorer. i've
searched alot but always i see the problem but with no solution can
any one Help me
i tried
e.consume
but nothing happened
thnx in advance
hiwa - 26 Aug 2007 06:18 GMT
On Aug 26, 12:41 am, maro20081...@forislam.com wrote:
> hi all,
> i have a problem in JPopupMenu that's supposed to appear when the user
[quoted text clipped - 5 lines]
> but nothing happened
> thnx in advance

It sounds like JComboBox.
See javax.swing.plaf.basic.BasicComboPopup
maro20081984@forislam.com - 26 Aug 2007 19:26 GMT
> See javax.swing.plaf.basic.BasicComboPopup
thanx for ur reply
I don't know if i didn't explain my problem or i don't understand your
point of view what i want is
i have a JMenuItem if the user  click on it, it will open the link but
if he right clicks on this menuItem a popupMenu will appear but in
the  same time the menuItem and Menu still be opened until he clicks
on the menuItem in the popUpMenu
like Favourite Menu
if the user click on a link it will be opened but right click on it
will open a popupMenu containing MenuItems (open,print...etc)
thnx again for ur care
Ray Ma - 28 Aug 2007 17:03 GMT
> like Favourite Menu
> if the user click on a link it will be opened but right click on it
> will open a popupMenu containing MenuItems (open,print...etc)

One way to achieve this is Swing I think, is to define the "pop-up"
behavior you want for your menuItem yourself.
Just because the "Favourite" Menu in IE can behave its way doesn't
mean you can simply do the same thing by using the
standard swing component behavior. The JMenuItem by default, won't pop
up anything by mouse click if you don't define any pop-up for it.
A JMenue, if it's a subMenu in a menu list and it has menuItems(such
as the IE->Favourite->Links), the Links will pop up
its MenuItem when your mouse move onto the "Links". This is standard
Swing behavior.

If you want mouse Pop up when user click on a MenuItem, you need to
addListener:
myMenuItem.addActionListener(new ActionListener(){
           public void actionPerformed(ActionEvent ae){
                JOptionPane.showOptionDialog(parent,"confirm
Msg","Confirm Dialog",

JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,
                                    null,myYesNoOptions,"yes");
                //Show a dialogWindow maybe
           }
});

If you want the MenuItem to popup sth when mouse Right click, you may
addMouseListener on that MenuItem,
and only reponse to Right click by:
          if((MouseEvent)me.getButton()==MouseEvent.Button3)
                //yourPopUpMenu.show();


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.