How do I call the function in the button section?? I tried doing target(); and got when the program ran, it gave me some exception thing..
package smart;
import java.applet.Applet;
import java.awt.AWTEvent;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.awt.image.WritableRaster;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.net.JarURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLClassLoader;
import java.net.URLEncoder;
import java.net.HttpURLConnection;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.util.Locale;
import java.util.HashMap;
import java.util.Map;
import java.util.Hashtable;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import sun.applet.AppletClassLoader;
public class Client implements ActionListener, ChangeListener {
public void target(Canvas it) {
if (it == canvas) {
return;
}
boolean iam = blocking;
if (iam) {
stopBlocking();
}
BlockingEventQueue.removeComponent(canvas);
if (canvas == null) iam = true;
canvas = it;
canvas.setRefresh(refresh);
if (blitThread != null) {
blitThread.stop();
}
blitThread = createBlitThread();
BlockingEventQueue.addComponent(canvas, new EventRedirect() {
@Override
public void dispatched(AWTEvent e) {
if ((e instanceof MouseEvent && e.getID() == MouseEvent.MOUSE_CLICKED) || (e instanceof KeyEvent)) {
clientFrame.requestFocusInWindow();
}
}
});
BlockingEventQueue.setBlocking(canvas, iam);
if (iam) {
startBlocking();
}
if (initseq != null) {
nazi.sendKeys(initseq);
initseq = null;
System.out.println("Init Sequence Dispatched");
}
blitThread.start();
}
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == blockingbtn) {
[B] //Call that target(); function here...[/B]
}
}