I'm not sure what I'm on, but I can't seem to get this right. I'm trying to reference a frame declared in one class from another class which is used exclusively to handle events.
In the first:
VB Code:
import java.awt.*; public class test { public Frame frmMain = new Frame("Test"); public static void main(String args[]) { test objTest = new test(); } public test() { frmMain.addMouseListener(new mouseEvents()); frmMain.setSize(100,100); frmMain.setLocation(400,400); frmMain.setVisible(true); } }
In the second:
VB Code:
import java.awt.event.*; public class mouseEvents extends MouseAdapter { public void mousePressed(MouseEvent e) { System.out.println(test.frmMain.getTitle()); } }
This is similar to what I'm trying to do. I get the "non-static variable frmMain cannot be referenced..." error on the println line.
![]()




Reply With Quote