Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pf.bot.loader;
- import java.applet.Applet;
- import java.applet.AppletStub;
- import java.awt.Color;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- public class ClientLoader extends Applet implements Runnable {
- private static final long serialVersionUID = 10L;
- private Applet applet;
- private ClassLoader loader;
- public synchronized final void destroy() {
- if (applet != null)
- applet.destroy();
- }
- public synchronized final void start() {
- if (applet != null)
- applet.start();
- }
- public synchronized final void stop() {
- if (applet != null)
- applet.stop();
- }
- public synchronized final void init() {
- Container container = getParent();
- if (null != container)
- container.setBackground(Color.black);
- setBackground(Color.black);
- Thread thread = new Thread(this, "Loader");
- thread.start();
- }
- public final void paint(Graphics g) {
- if (applet != null)
- applet.paint(g);
- else {
- String status = "Loading...";
- g.setColor(Color.WHITE);
- FontMetrics fm = g.getFontMetrics();
- g.drawString(status, (getWidth() - fm.stringWidth(status)) / 2,
- getHeight() / 2);
- }
- }
- public final void update(Graphics g) {
- if (applet != null)
- applet.update(g);
- }
- public Applet getApplet() {
- return applet;
- }
- @Override
- public void run() {
- try {
- loader = new ClientClassLoader();
- Class<?> app = loader.loadClass("client");
- applet = (Applet) app.newInstance();
- app.getMethod("provideLoaderApplet", new Class[] { Applet.class })
- .invoke(null, this);
- AppletStub stub = new ClientStub(applet);
- this.setStub(stub);
- applet.init();
- applet.start();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment