Guest User

Untitled

a guest
May 21st, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. package pf.bot.loader;
  2.  
  3. import java.applet.Applet;
  4. import java.applet.AppletStub;
  5. import java.awt.Color;
  6. import java.awt.Container;
  7. import java.awt.Dimension;
  8. import java.awt.FontMetrics;
  9. import java.awt.Graphics;
  10.  
  11. public class ClientLoader extends Applet implements Runnable {
  12.  
  13. private static final long serialVersionUID = 10L;
  14.  
  15. private Applet applet;
  16.  
  17. private ClassLoader loader;
  18.  
  19. public synchronized final void destroy() {
  20. if (applet != null)
  21. applet.destroy();
  22. }
  23.  
  24. public synchronized final void start() {
  25. if (applet != null)
  26. applet.start();
  27. }
  28.  
  29. public synchronized final void stop() {
  30. if (applet != null)
  31. applet.stop();
  32. }
  33.  
  34. public synchronized final void init() {
  35. Container container = getParent();
  36. if (null != container)
  37. container.setBackground(Color.black);
  38. setBackground(Color.black);
  39. Thread thread = new Thread(this, "Loader");
  40. thread.start();
  41. }
  42.  
  43. public final void paint(Graphics g) {
  44. if (applet != null)
  45. applet.paint(g);
  46. else {
  47. String status = "Loading...";
  48. g.setColor(Color.WHITE);
  49. FontMetrics fm = g.getFontMetrics();
  50. g.drawString(status, (getWidth() - fm.stringWidth(status)) / 2,
  51. getHeight() / 2);
  52. }
  53. }
  54.  
  55. public final void update(Graphics g) {
  56. if (applet != null)
  57. applet.update(g);
  58. }
  59.  
  60. public Applet getApplet() {
  61. return applet;
  62. }
  63.  
  64. @Override
  65. public void run() {
  66. try {
  67. loader = new ClientClassLoader();
  68. Class<?> app = loader.loadClass("client");
  69. applet = (Applet) app.newInstance();
  70. app.getMethod("provideLoaderApplet", new Class[] { Applet.class })
  71. .invoke(null, this);
  72. AppletStub stub = new ClientStub(applet);
  73. this.setStub(stub);
  74. applet.init();
  75. applet.start();
  76. } catch (Exception e) {
  77. e.printStackTrace();
  78. }
  79. }
  80.  
  81. }
Add Comment
Please, Sign In to add comment