I am learning to build GUIs, specifically for building dynamic queries and displaying the results to the users in real-time.
I designed a prototype, with JLists, JTextFields, and a JTable. To accomodate layout the way I want it, while still using a Layout manager (BoxLayout and FlowLayout), I am nesting components. Basically, I have a JFrame, with a main JPanel in the center, and that JPanel is laid out vertically, and contains two more JPanels, the bottom one contains a JTable, the top contains four panels laid out horizontally, etc. etc.
So it occurred to me that, I am embedding components inside other components, yet I am doing it in one big class. I am not sure where to draw the lines (pardon the pun) with separate classes.
For example, should I make a subclass of JPanel, that contains a JLabel and a JList, then place a ref variable to one of those objects in another subclass of JPanel, which in turn will be represented by another ref variable in another subclass of JPanel?
It just doesn't feel that 'object oriented' if everything for the GUI is embedded in one large class. Any advice would be greatly appreciated.
If you've got, say, a dozen components I wouldn't worry about about the nested containers. If you would be ok putting them all in a single BoxLayout or FlowLayout, then I don't see how it's any less "object oriented" to put them in a half-dozen nested JPanels instead.