Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.java.* > Newsgroup comp.lang.java.gui

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 04-28-2006, 04:35 PM
MikeSmith813@gmail.com
Guest
 
Posts: n/a
Default JPanel Listener Problem

I have a JApplet that contains a JPanel. The JPanel contains
JComponents, each of which have a FocusListener. On FocusGained I do
something with the JComponent.

My problem is that I need the JApplet class to know each time the
FocusGained() method is invoked inside the JPanel and it needs to do
something based on the JComponent selected.

How do I implement a listener on the JPanel in the JApplet class that
will know when one of the components is clicked.

I tried adding a MouseListener, FocusListener, and a ContainerListener
to the JPanel and I've been unable to determine when a component was
clicked with each.

Any help would be great!

Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 04-28-2006, 05:20 PM
Knute Johnson
Guest
 
Posts: n/a
Default Re: JPanel Listener Problem

MikeSmith813@gmail.com wrote:
> I have a JApplet that contains a JPanel. The JPanel contains
> JComponents, each of which have a FocusListener. On FocusGained I do
> something with the JComponent.
>
> My problem is that I need the JApplet class to know each time the
> FocusGained() method is invoked inside the JPanel and it needs to do
> something based on the JComponent selected.
>
> How do I implement a listener on the JPanel in the JApplet class that
> will know when one of the components is clicked.
>
> I tried adding a MouseListener, FocusListener, and a ContainerListener
> to the JPanel and I've been unable to determine when a component was
> clicked with each.
>
> Any help would be great!
>


One way is to put a method in the applet that you can call from your
component focus listener.

--

Knute Johnson
email s/nospam/knute/
Reply With Quote
  #3 (permalink)  
Old 05-01-2006, 11:47 AM
MikeSmith813@gmail.com
Guest
 
Posts: n/a
Default Re: JPanel Listener Problem

Is that the only way? There's no listener that I can put on the JPanel
within the applet? It seems odd to have the JPanel send control back
to the Applet from the focus listener. What if the JPanel isn't
finished executing at the time that I need the Applet to execute
another process?

Reply With Quote
  #4 (permalink)  
Old 05-01-2006, 05:46 PM
ArthurP
Guest
 
Posts: n/a
Default Re: JPanel Listener Problem

Creat a new class of listener that the Applet listens to and that the
JComponent fires.

Reply With Quote
  #5 (permalink)  
Old 05-01-2006, 06:17 PM
Knute Johnson
Guest
 
Posts: n/a
Default Re: JPanel Listener Problem

MikeSmith813@gmail.com wrote:
> Is that the only way? There's no listener that I can put on the JPanel
> within the applet? It seems odd to have the JPanel send control back
> to the Applet from the focus listener. What if the JPanel isn't
> finished executing at the time that I need the Applet to execute
> another process?
>


You will have to write your own. Here is a really good article on how
to do that:

http://www.javaworld.com/javaworld/j...javatip35.html

I think I would use the suggestion I gave you unless this is an exercise
in OO.

--

Knute Johnson
email s/nospam/knute/
Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: SAS Problem nospam@HOWLES.COM (Howard Schreier Newsgroup comp.soft-sys.sas 0 05-03-2006 03:23 AM
Re: SAS ETL- is Password Protection for files a problem? GE Consumer Finance Newsgroup comp.soft-sys.sas 1 01-18-2006 09:17 AM
SAS -> MSWord DDE problem: report Howard Cherniack Newsgroup comp.soft-sys.sas 0 05-29-2005 10:11 AM
Re: Help on a grouping problem nospam@HOWLES.COM (Howard Schreier Newsgroup comp.soft-sys.sas 0 02-16-2005 02:52 AM
Re: Help on a grouping problem Sigurd Hermansen Newsgroup comp.soft-sys.sas 0 02-15-2005 11:49 PM



All times are GMT. The time now is 01:40 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.