This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Ok, I have worked with Swing and been able to make basic GUI's, ActionListener's etc.. But I don't have a firm grasp on all the different objects. What is the relationship between JFrame and JPanel. If I have one do I have to have the other. Do frame go into panel or vice versa? What about container's and windows? I think some of the problem in that Swing is built on AWT which adds to the confusion. Can anyone explain in simpler terms an overview of these classes? I have read manuals of web pages but they all seem to say different things. Any help would be welcome. Bill
Both Frame and Panel are containers. A Frame has a Border and Titlebar, a Panel does not. A Frame is a sub-class of window which means that a Frame is an outermost container. Therefore you can not put a Frame in a Panel. You CAN put a Panel in any of the areas of Frame. An Applet is a sub-class of Panel. Frame has BorderLayout as its default LayoutManager. Panel has FlowLayout as its default LayoutManager. You can use Panels to stack inside each other to create your desired Look. For instance you can give a Panel a GridLayout that is 2X3 and then in each of the grid cells you can put different Panels, each doing something different, etc. You should have a good grasp of the AWT before expanding into Swing.
"JavaRanch, where the deer and the Certified play" - David O'Meara