Hello everybody, I am brand new in GUI, so bare with my simple questions here: I am trying to create a GUI that has 3 textFields, for inputting search strings. Then, a "Submit" button below them , to execute the search. Finally, I would like a JTable , either to the right or bottom of the search field/button to display the results. However, although the textfields and the button works correctly, I cannot make JTable to appear coorectly. I am doing BorderLayout_SOUTH / CENTER / etc for my search fields and button. THen, my JTable either overlapps my button (when I give the BorderLayout_South as coordinate again) or it dont even show up when i put parameter as BorderLayout_East. Whats other way to manage these panels? Also, I wont be able to know how big my JTable will be until I hit the "Submit" button... THanks for helping out!! Jack
Craig Wood
Ranch Hand
Joined: Jan 14, 2004
Posts: 1535
posted
0
KR Campbell
Ranch Hand
Joined: Mar 26, 2004
Posts: 124
posted
0
Or at a more abstract level; if you are using a BorderLayout you cannot add more than one component in each part of the layout. So if you add a button to BorderLayout.CENTER and then add a JTable to the same section one of them is not going to be visible. As the previous correspondent has so ably demonstrated, a good solution is to nest panels within each other. Regards, Kenny
Glenn Murray
Ranch Hand
Joined: Dec 07, 2001
Posts: 74
posted
0
Yes, the idea which you seem to be missing is that you can nest the panels (with their layouts) in one another. Here's a modification of the example above which shows that more clearly, I think, and has the further of advantage of not farting around with GridBagLayout (it's a newbie question for crying out loud). Note that columnPanel with the GridLayout is nested in northPanel which has the default FlowLayout---the only purpose being to provide nice padding. You can experiment by adding columnPanel instead of northPanel in line 25. Cheers, Glenn