File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes Multiple applets invocation from single applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Multiple applets invocation from single applet" Watch "Multiple applets invocation from single applet" New topic
Author

Multiple applets invocation from single applet

c shah
Greenhorn

Joined: May 12, 2011
Posts: 10
I am doing translation of car using applets.
I have a car in first applet and in the next applets car moves slightly.(Total 5 applets.car moves from x=50 to x=250.)
I am not able to call those applets from my main applet.I am not using repaint because i want to show car movement in different windows(frames).
I have written code for 2 applets.I think i am wrong in calling paint of second applet from my first applet.
can i do this using java swings?
Please guide me.
\\Main applet
import java.applet.*;
import java.awt.*;

public class HelloWorldApplet extends Applet
{
private int x, y;

public void init( )
{
x = 50;
y = 50;
}

public void paint(Graphics g)
{
g.drawRect(x, y, 200, 100);
setBackground(Color.black);
g.setColor(Color.RED);
g.fillRect( x, y, 200, 100 );
g.drawOval(55,150,40,40);
g.drawOval(205,150,40,40);
g.fillOval(55,150,40,40);
g.fillOval(205,150,40,40);

}
Applet2 secondApp = (Applet2)getAppletContext().getApplet("secondapplet");
secondApp.draw();


}
\\Applet which is to be invoked.
import java.applet.*;
import java.awt.*;

public class Applet2 extends Applet
{
private int x, y;
Graphics a;
public void init( )
{
x = 90;
y = 50;
}
public void draw()
{
paint(a);
}
public void paint(Graphics g)
{
g.drawRect(x, y, 200, 100);
setBackground(Color.black);
g.setColor(Color.RED);
g.fillRect( x, y, 200, 100 );
g.drawOval(95,150,40,40);
g.drawOval(245,150,40,40);
g.fillOval(95,150,40,40);
g.fillOval(245,150,40,40);
}
}


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple applets invocation from single applet