I'm following some tutorials, and this confused me.
JFrame container = new JFrame("name");
JPanel panel = (JPanel) container.getContentPane();
This is the constructor method for a class which extends Canvas. The JFrame and JPanel where not established before this constructor.. How can they work? I was under the impression they would no longer exist outside the method.
Also whats going on with the Panel? After googling I still dont understand the getContentPane() method. I've seen people using 'getContentPane().add(something);' - from all the books I've read, they just added things without that extra method. And finally, why is this tutorial putting a Canvas into a JPanel into a JFrame.. I find this all very confusing.
One of the problems this is causing me now is that I can no longer use getSize() to find the width or height. It always returns the initial values, and the JFrame or Panel can't be found outside this constructor.
If anyone could clear this up this up for me I'd be really thankful