• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Repaint and ComponentListener

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please look into this problem. I have tried to state the problem in simple terms.
Class A extends Canvas.
Class B extends applet and has Cardlayout
The first card is a panel,has borderlayout.
- This contains an instance of "A" in the "CENTER"
- Also, has a panel with a textfield in "SOUTH"
When I leave the browser window containing the applet, and return.
the Canvas in the center is repainted and refreshes itself. But the lower panel is not reset. (The textfield still retains the previous state).
To reset the textfield, I tried to implement class B as a ComponentListener and tried reseting the textfield values in
componentShown(ComponentEvent ce) method of the inteface. Doesnt seem to work on the textfield ?
Is this the right approach ? if so, why would this be not working ?
[ June 26, 2002: Message edited by: Jennifer Wallace ]
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you revalidateing?
 
Jennifer Wallace
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks ! validate() resets my textfield beautifully. Sorry for the delayed response. Just saw your reply today.
But looks like I have worked up with the wrong listener. Because apparently, the componentshown method of Component Listener is invoked only once initially (atleast in my code) and is not invoked when the applet is repainted on re gaining focus. This contradicts what I saw in the demo applet of java tutorial. Would this not work on applets ?
Also, I tried a couple of others. They didn't work as well - Focus Listener, WindowFocuslistener, WindowListener (the last 2 work only for windows!)
Which listener should I be using, to capture the moment of my return to the applet screen ?
Thanks,
Jennifer
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jennifer Wallace:
Thanks ! validate() resets my textfield beautifully. Sorry for the delayed response. Just saw your reply today.
But looks like I have worked up with the wrong listener. Because apparently, the componentshown method of Component Listener is invoked only once initially (atleast in my code) and is not invoked when the applet is repainted on re gaining focus. This contradicts what I saw in the demo applet of java tutorial. Would this not work on applets ?
Also, I tried a couple of others. They didn't work as well - Focus Listener, WindowFocuslistener, WindowListener (the last 2 work only for windows!)
Which listener should I be using, to capture the moment of my return to the applet screen ?
Thanks,
Jennifer


I think MouseMotionListener and MouseListener will allow you to know your presence in the applet
 
Jennifer Wallace
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think Mouse Listeners will not work for me because I want the applets components to be validated when the web page containing the applet gains focus and not wait until the mouse enters the applet.
Also, looks like componentShown method of ComponentListener (Definiton of which is - Invoked when the component has been made invisible) doesn't correspond to the applet window going out of view and getting back focus. I think the demo applet in Sun's Website also demonstrates similar activity.
In fact, the solution would be to validate my components in the applet's paint method. And this works fine and resets my textfield everytime the applet is repainted.
 
reply
    Bookmark Topic Watch Topic
  • New Topic