我可以从面板访问创建 JFrame 的 class 变量 and/or 方法吗?

Can I acces variables and/or methods of the class a JFrame was created in from the panel?

缩短代码:

public class Test{
  private JFrame frame;
  private TestPanel panel;
  
  Object obj;
 
  public static void main(String args[]) {
    Test test = new Test();
  }

  public Test() {
    try {
      // Setup GUI
      frame = new JFrame("Test");
      panel = new TestPanel();
      frame.add(panel);
    }
  }
}

是否可以直接从面板访问obj? 如果是:如何?

提前感谢您的帮助。 :)

否;不是没有将对对象的引用传递给面板。