-1

我想知道在已加载的小程序上渲染我自己的图形的最佳/最简单方法是什么:

public class Game {

    public static Applet applet = null;
    public static URLClassLoader classLoader = null;

    public static void load() {
        try {
            classLoader = new URLClassLoader(new URL[]{Jar.getJar().toURL()});
            applet = (Applet) classLoader.loadClass("com.funkypool.client.PoolApplet").newInstance();
            applet.setSize(new Dimension(800, 600));
            applet.setBackground(Color.BLACK);
            applet.setStub(new Stub());
            applet.init();
            applet.start();

            JFrame loader = new JFrame("Loader");
            loader.setPreferredSize(applet.getSize());
            loader.add(applet);
            loader.pack();
            loader.setVisible(true);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

我希望它在小程序上呈现,但小程序仍然保持其所有原始功能,我相信我可能需要使用反射?我正在考虑查看 Powerbot.org 在 runescape 客户端上呈现的方式,因为客户端仍然保持其所有功能等。

如果您有任何问题或需要查看更多代码,请提出。

4

1 回答 1

0

Assuming this draws something (my applet-fu is rusty), then you can draw on top of it by placing it in a JFrame and subclassing the JFrames' void paint(Graphics g) so that it paints whatever it wants to, and then paints something else.

A modified JFrame that does this could be the following (warning: untested code):

public static class OverlayJFrame extends JFrame {
     private JPanel overlay;
     public OverlayJFrame(String title) { super(title); }
     public void setOverlay(JPanel overlay) { this.overlay = overlay; }
     public void paint(Graphics g) { super.paint(g); overlay.setSize(getSize()); overlay.paint(g)); }
}
于 2013-01-12T22:49:59.237 回答