JTabbedPane is an actual component. JPanel is a component also but it really offers no additional functionality other then to group components.What is the difference between a panel and a pane? They are both used often, but why is it JTabbedPane and JPanel and not the other wayaround? Any reason?...
I used to be confused with this also. And i would often forget to add components to the content pane instead of say a JFrame which causes a compilation error.Why do you sometimes use .add (eg. JPanel) and sometimes .getContentPane().add (eg. JInternalDialog)?
.getContentPane().add (eg. JInternalDialog) that you are refering to is a short hand alternative. You can code it like this if you wanted to(as i often do)
Code:JFrame jf = new JFrame("Hello"); Container c = jf.getContentPane(); c.add(jc);




Reply With Quote