VB Code:
import java.awt.*;
import java.awt.event.*;
public class test {
private Frame frmMain = new Frame("test");
private TextArea txtMain = new TextArea("");
private Button b1 = new Button("Dialog");
public static void main (String args[]) {
test objTest = new test();
}
public test() {
frmMain.setSize(400,400);
frmMain.setLayout(new BorderLayout());
// pass this as parameter
b1.addActionListener(new buttonEvents(this));
frmMain.add(b1, BorderLayout.SOUTH);
frmMain.setVisible(true);
}
}
VB Code:
import java.awt.*;
import java.awt.event.*;
public class buttonEvents implements ActionListener {
test objTest = null;
// use the constructor to get a reference to the main object
public buttonEvents(test objSource) {
this.objTest = objSource;
}
public void actionPerformed(ActionEvent e) {
// some code in here for the event, and can use objTest to refer back to the original object
}
}