Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #1233 > unrolled thread
| Started by | "RC" <rc@THRWHITE.remove-dii-this> |
|---|---|
| First post | 2011-04-27 15:32 +0000 |
| Last post | 2011-04-27 15:32 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.java.gui
How can JComboBox listene "RC" <rc@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
Re: How can JComboBox lis "Tom Hawtin" <tom.hawtin@THRWHITE.remove-dii-this> - 2011-04-27 15:32 +0000
Re: How can JComboBox lis phillip.s.powell@gmail.co.remove-dii-this - 2011-04-27 15:32 +0000
| From | "RC" <rc@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:32 +0000 |
| Subject | How can JComboBox listene |
| Message-ID | <etms18$efe$1@news.nems.noaa.gov> |
To: comp.lang.java.gui,comp.l
Since JComboBox and JButton both are
extends from JComponent.
When I addMouseListener(this);
for jButton, it listens to the MouseEvent.
But jComboBox doesn't listen to the MouseEvent.
public void mouseEntered(MouseEvent me) {
System.out.println("mouse entered");
jComboBox.setToolTipText("mouse entered"); // not work
jButton.setToolTipText("mouse entered button"); // works fine
}
mouseEntered just move your mouse pointer on
the object, no need to click (pressed and released).
I just want to detect the mouse entered on JComboBox
(i.e. popup a ToolTip) before I click it for select an item.
Do I miss something? Do I need to setXXX and/or enableXXX
JComboBox before I addMouseListener?
Thank Q for your help!
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [next] | [standalone]
| From | "Tom Hawtin" <tom.hawtin@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:32 +0000 |
| Subject | Re: How can JComboBox lis |
| Message-ID | <45fef787$0$8724$ed2619ec@ptn-nntp-reader02.plus.net> |
| In reply to | #1233 |
To: comp.lang.java.gui,comp.l RC wrote: > > Since JComboBox and JButton both are > extends from JComponent. > When I addMouseListener(this); > for jButton, it listens to the MouseEvent. > But jComboBox doesn't listen to the MouseEvent. JComboBox is implemented as a number of components (a text field, the button and the container for them both). If you add a low level listener to the container, it wont receive the events of its children. Oddly, mouse events do bubble up if the child has no mouse listeners. Unfortunately if you add mouse listeners recursively, you might end up preventing events bubbling up that the PL&F expects. As an alternative, you can either push an EventQueue and filter through dispatched events, or add an AWTEventListener through Toolkit. But probably what you want to do is reconsider what you were doing in the first place. Tom Hawtin [Followup-To: comp.lang.java.gui] --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | phillip.s.powell@gmail.co.remove-dii-this |
|---|---|
| Date | 2011-04-27 15:32 +0000 |
| Subject | Re: How can JComboBox lis |
| Message-ID | <1174504576.800515.29460@e65g2000hsc.googlegroups.com> |
| In reply to | #1233 |
To: comp.lang.java.gui,comp.l
On Mar 19, 4:29 pm, RC <raymond.c...@nospam.noaa.gov> wrote:
> Since JComboBox and JButton both are
> extends from JComponent.
> When I addMouseListener(this);
> for jButton, it listens to the MouseEvent.
> But jComboBox doesn't listen to the MouseEvent.
>
> public void mouseEntered(MouseEvent me) {
> System.out.println("mouse entered");
> jComboBox.setToolTipText("mouse entered"); // not work
> jButton.setToolTipText("mouse entered button"); // works fine
>
> }
>
> mouseEntered just move your mouse pointer on
> the object, no need to click (pressed and released).
>
> I just want to detect the mouse entered on JComboBox
> (i.e. popup a ToolTip) before I click it for select an item.
>
> Do I miss something? Do I need to setXXX and/or enableXXX
> JComboBox before I addMouseListener?
>
> Thank Q for your help!
I am not thinking that you'd want a MouseListener for the JComboBox,
but instead consider a PopupMenuListener instead, chances are that
will give you the results you want within the JComboBox.
Phil
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.gui
csiph-web