import java.awt.*;
import java.awt.event.*;
class MyCanvas extends Canvas
{
public void paint(Graphics g)
{ g.setColor(new Color(255,0,0));
g.fillOval(5,5,20,20);
g.setColor(Color.blue);
g.fillOval(40,10,20,20);
g.setColor(Color.yellow);
g.fillRect(10,20,40,50);
}
}
public class TestCanvas
{
Frame f;
void Launchmc()
{
MyCanvas mc=new MyCanvas();
f=new Frame("drawings");
f.add(mc);
f.setSize(300,200);
f.setVisible(true);
f.addWindowListener(
new WindowAdapter(){ public void windowClosing(WindowEvent e)
{ System.exit(0);
}
});
}
public static void main(
String args[])
{
TestCanvas tc=new TestCanvas();
tc.Launchmc();
}
}
Why is it that I can make object of MyCanvas class in Launchmc() method
and also access that object from Launchmc(),MyCanvas class is not public