I have an outer class. I also have a private inner class that extends JPanel. This is the design of the code.
public class Outer{
private class Inner extends JPanel{
public void doSomeWork(){}
}
public Outer(){
Inner inner = new Inner();
inner.doSomeWork();
}
public static void main(String args[]){
Outer outer = new Outer();
}
}
I am not being able to access the doSomeWork() method of the inner class from the outer class. Please help.
Here is how you make an object of inner and access its variables...
Outer outer = new Outer();
Outer.Inner inner = outer.new Inner();
inner.doSomeWork();
Example code from Oracle is here...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With