Re: JList gets moved around in layout after data is added to it



On Mon, 25 Jul 2005 02:36:41 GMT, Brandon McCombs <bmccombs@xxxxxxxxx>
wrote:

>hello,
>
>I have a JList in a panel next to(to the right) some textfields/buttons
>in another panel. I'm using the gridbaglayout. When I'd add data to
>the Jlist the Jlist would resize about 100 pixels I guess and would
>squeeze the textfields/buttons in the adjacent panel into a smaller
>area despite the fact that the data in the Jlist did not need that much
>room (i had lots of whitespace at teh end of each entry in the Jlist).
>I just switched to putting both of these panels into a tab within a
>JtabbedPane and now when I add entries to the Jlist the Jlist gets
>shifted down and off the viewable area of the Jframe while the other
>panel (textfields/buttons) gets centered in the vieweable area.

I don't know offhand what the default layout manager for a JTabbedPane
is, but it sounds as if it might be FlowLayout, with the JList (now)
too big to fit on the same line as the other panel.
>I
>consider this worse than previously without the jtabbedpane since I
>can't even see the Jlist contents w/o resizing the jframe window.
>Without having to show any code (it might be hard to show it b/c my code
>is getting more involved but i can try to post some if needed), does any
>one know what the resizing of the Jlist and rearranging of it in my
>layout can be caused by off hand? Is it due to the gridbaglayout and a
>certain property of the constraints or something else possibly?
>
I don't know GridbagLayout well - I hate it like poison and never use
it. Have you tried BoxLayout? I tend to use JPanelS with BoxLayout
inside JPanelS with BoxLayout, or BorderLayout for some things, and if
those don't work, I write my own LayoutManager (which sounds more
difficult than it is).

Pete Barrett
.


Quantcast