File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes applet refresh event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "applet refresh event" Watch "applet refresh event" New topic

applet refresh event

sandeep dhingra
Ranch Hand

Joined: Jul 30, 2005
Posts: 41
hi all,
please help me in this problem....
i have a applet running which is connected to the server. which is showing the data from the database.
What i have to do is to capture the refresh event and when the user presses the refresh button i have to call a function. How can i do it.
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
What have you tried so far? What do you have problems with?

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
sandeep dhingra
Ranch Hand

Joined: Jul 30, 2005
Posts: 41
while searching on the net. i found out that by using java script i can disable the refresh button by using this code

script language=java script
var a=0
function refresh()
if (116==event.key Code)
return false;

document on keydown = function (){ refresh(); }

function logout()
write your code.....
window on unload = function(){
else if(event client X >0 && event client Y<0)
else if(event.client X<0 && event.client Y<0)

but what i want to do is capture the event and when it is pressed i want to handle it according to me.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
So is this question about Java and/or applets at all, of are you looking to do something solely in JavaScript?
sandeep dhingra
Ranch Hand

Joined: Jul 30, 2005
Posts: 41
What I have found out on the internet i have written, that it can be controlled by using javascript. but i want to know that cant the refresh event be handled by using event handling in java.
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

What Applet lifecycle methods are you using in your program?

The first time the user enters the page init() is called, then start(). Any time the user leaves the page, stop() is called. If the user returns to the page, only start() by itself is called. At some point destroy() is called to get rid of the applet, like if the web browser is closed, or the JVM runs low on memory, etc.

The problem is that different browsers (and browser versions) handle refresh differently - some browsers just call stop() and start(), some completely unload the applet and do a full stop(), destroy(), and init(), start() on a new instance.

You'll have to test it out and see what combination works best in your situation.

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: applet refresh event
It's not a secret anymore!