Forums Register Login

applet & destroy()

+Pie Number of slices to send: Send
Hi,
someone asked me a question the other day and I got curious myself.
The problem he has is this: he's running Netscape to try out an applet he made, but when he closes Netscape he found out that the system isn't giving him back all the resources. He has to kill the process with Ctrl-Alt-Del (he's running 95).
Looks like a thread is still active. Now this should be handled with stop() and destroy() I think.
Could anyone give me an example in the form of a small very simple applet where explicitly destroy() is used to make sure all threads are killed (sounds kinda violent eh?).
I appreciate it!
Patrick
+Pie Number of slices to send: Send
Hi,
Could u elaborate as to which process is still running after closing the Netscape browser?
Nitin

------------------
Anthrax
+Pie Number of slices to send: Send
Thanks for your reaction. I will ask this question to the person who asked me the question.
Is there a general way though where you can explicitly tell the applet to destroy itself (and thus all it's threads/processes)?
Appreciate the input!!
Patrick
+Pie Number of slices to send: Send
Call explicitly the applet's destroy method in your code.
------------------
Suneel
+Pie Number of slices to send: Send
humm,yes, that's what I suspected, but what would this look like? Suppose you have the applet that I will add here after, how would you use the destroy() method?
I would appreciate it if someone could rebuild this code so the applet will explicitly destroy itself.
Thanks!
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class MoveMe extends JApplet
{
Container theContainer;
JButton theButton;
public void init()
{
theContainer = this.getContentPane();
theContainer.setLayout(null);
theButton = new JButton("Move Me With the Mouse");
theContainer.addMouseMotionListener(new Chaser());
theContainer.add(theButton);
theButton.setBounds(0, 0, 150, 35);
}
public class Chaser extends MouseMotionAdapter
{
public void mouseMoved(MouseEvent me)
{
theButton.setSize( 150 + me.getX(), 35 + me.getY() );
theButton.setLocation(me.getX()+3, me.getY()+3);
}
}
}
+Pie Number of slices to send: Send
 

Originally posted by Patrick Lentz:
humm,yes, that's what I suspected, but what would this look like? Suppose you have the applet that I will add here after, how would you use the destroy() method?
I would appreciate it if someone could rebuild this code so the applet will explicitly destroy itself.
Thanks!
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class MoveMe extends JApplet
{
Container theContainer;
JButton theButton;
public void init()
{
theContainer = this.getContentPane();
theContainer.setLayout(null);
theButton = new JButton("Move Me With the Mouse");
theContainer.addMouseMotionListener(new Chaser());
theContainer.add(theButton);
theButton.setBounds(0, 0, 150, 35);
}
public class Chaser extends MouseMotionAdapter
{
public void mouseMoved(MouseEvent me)
{
theButton.setSize( 150 + me.getX(), 35 + me.getY() );
theButton.setLocation(me.getX()+3, me.getY()+3);
}
}
}


+Pie Number of slices to send: Send
Since you don't have any threads or let's say Graphics object to kill
how about this?:
public void distroy()
{
theContainer = null;
theButton = null;
}
+Pie Number of slices to send: Send
Hi
This is based on swing.
Try this. It works
public void remove(){
remove(theContainer);
}
Regards
Suneel
Hey! You're stepping on my hand! Help me tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1764 times.
Similar Threads
odbc question
How to view Oracle Applications applet on netscape browser running on Redhat 7.1 OS?
how to access oracle financials 11.0.5 on netscape 4.78 which runs on redhat 7.1
destroy() question
Applet Sequence in Browser
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:51:54.