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 / November 2003

Tip: Looking for answers? Try searching our database.

JComboBox popup sensing mouse clicks

Thread view: 
wex - 04 Nov 2003 07:30 GMT
I am have written a custom combo box and want to fire events when the
user selects  choices.  I consider selecting to be either scrolling
down the list and pressing enter or  clicking on  a choice with the
mouse.  Scrolling down the list and pressing enter is easily sensed
with the action listener.

But I can not figure out how to sense the mouse clicks  I have tried
many avenues.  I have added an itemlistener which senses selection
changes but it fires even when the user presses the arrow keys so that
doesn't help.  Essentially I need to add a mouse listener to the popup
component of the

Help!!!
ak - 04 Nov 2003 08:13 GMT
I think you ask second time.
See http://www.imagero.com/java/mcb/

> I am have written a custom combo box and want to fire events when the
> user selects  choices.  I consider selecting to be either scrolling
[quoted text clipped - 9 lines]
>
> Help!!!
wex - 04 Nov 2003 16:09 GMT
This code doesn't have any mouse listener on it so it really doesn't
help.   The closest i have come is putting a listener on the combo
button but that doesn't solve my problem.  I need a mouse listener on
the choices or the whole popup list???

> I think you ask second time.
> See http://www.imagero.com/java/mcb/
[quoted text clipped - 12 lines]
> >
> > Help!!!
ak - 04 Nov 2003 19:39 GMT
> This code doesn't have any mouse listener on it so it really doesn't
help.
because I extended JComboBox and such things are handled by JComboBox.
It is always better to extend something existing then write it from scratch.

> > I think you ask second time.
> > See http://www.imagero.com/java/mcb/
[quoted text clipped - 12 lines]
> > >
> > > Help!!!
wex - 04 Nov 2003 23:01 GMT
Alright well thanks.  But I still am looking for answer to my question
which I will repeat:  Does anyone know how th add a mouse listener to
the actual popup box of the jcombobox in order to register clicks on
the particular items?
Any help appreciated

> > This code doesn't have any mouse listener on it so it really doesn't
> help.
[quoted text clipped - 19 lines]
> > > >
> > > > Help!!!
Bryan E. Boone - 05 Nov 2003 02:48 GMT
The popup part is really a JPopupMenu.  What you'll want to do is grab the
popup menu
when you create this guy and add an ActionListener to the menu items.
(and a PopupMenuListener to the popup menu)

You should probably add the actionlistener when you get a
popupWillBecomeVisible message.

I had to so something similar when I created a calender ui component that
looked like
the one in OutLook.  The combo box had an editable date, but when it popped
up, it displayed a calendar ui.

Under the covers, I grabbed the popup menu and removed all the items from it
and then added
my calendar ui when I got the popupWillBecomeVisible message.

-Bryan

> Alright well thanks.  But I still am looking for answer to my question
> which I will repeat:  Does anyone know how th add a mouse listener to
[quoted text clipped - 25 lines]
> > > > >
> > > > > Help!!!


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.