• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

applet refresh event

 
sandeep dhingra
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you tried so far? What do you have problems with?
 
sandeep dhingra
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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(){
if(a==116)
{
a=0;
return;
}
else if(event client X >0 && event client Y<0)
return;
else if(event.client X<0 && event.client Y<0)
logout();
}



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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No!
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
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic