日期:2014-05-20 浏览次数:20837 次
public class A extends JPanel{ private B b = new B(); public void a(){ System.out.println(b.getData()); } public static void main(String[] args){ } } class B extends JPanel{ private Object o = new Object(); public Object getData() { return o; } }
------解决方案--------------------
import javax.swing.*; @SuppressWarnings("serial") public class A extends JPanel { private B b; public A(){ b = new B(); } public void a() { b.gg(); } public static void main(String[] a) { A aa = new A(); aa.a(); } } @SuppressWarnings("serial") class B extends JPanel { public void gg(){ System.out.println("abcdefg"); } }