Hello, I have been working on making a simple color bot for osrs. However, I am having a very hard time getting a mouse listener to work. Does anyone see anything wrong with the following code by any chance?
PHP Code:
class createApplet extends Applet implements AppletStub, MouseListener{
Applet applet = this;
public createApplet () {
downloadAndCreate();
}
public void init() {
addMouseListener(this);
}
/**
* downloads the game pack, then creates the applet.
*/
public void downloadAndCreate() {
/*
Downloads the game pack from the website using parameters
*/
Utilities.downloadFile(parameters.getParameter("codebase") + parameters.getParameter("initial_jar"), Utilities.getContentDirectory() + "game/" + (oldschool ? "os-" : "rs3-") + "gamepack.jar");
final File jar = new File(Utilities.getContentDirectory() + "game/" + (oldschool ? "os-" : "rs3-") + "gamepack.jar");
/*
Create a new URLClassLoader using the jar
*/
URLClassLoader classLoader = null;
try {
classLoader = new URLClassLoader(new URL[]{jar.toURI().toURL()});
} catch (MalformedURLException e) {
e.printStackTrace();
}
final String mainClass = parameters.getParameter("initial_class").replaceAll(".class", "");
try {
applet = (Applet) classLoader.loadClass(mainClass).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException a) {
a.printStackTrace();
}
applet.setStub(this);
applet.init();
applet.start();
}
@Override
public void mouseClicked(MouseEvent e) {
System.out.println("test");
}
@Override
public void mousePressed(MouseEvent e) {
System.out.println("test");
}
@Override
public void mouseReleased(MouseEvent e) {
System.out.println("test");
}
@Override
public void mouseEntered(MouseEvent e) {
System.out.println("test");
}
@Override
public void mouseExited(MouseEvent e) {
System.out.println("test");
}
}
public class loader extends JPanel {
/*
The applet instance
*/
private createApplet applet= new createApplet();
public loader(final boolean oldschool) {
/*
Set panel layout to BorderLayout
*/
setLayout(new BorderLayout());
add(applet.getApplet(), BorderLayout.CENTER);
revalidate();
}
}