Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / July 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Brandon McCombs - 25 Jul 2005 03:36 GMT
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
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?

thanks
Pete Barrett - 25 Jul 2005 19:10 GMT
>hello,
>
[quoted text clipped - 8 lines]
>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
[quoted text clipped - 4 lines]
>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
Brandon McCombs - 25 Jul 2005 23:58 GMT
> >hello,
> >
[quoted text clipped - 12 lines]
> 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.

But the thing is that the JList has no trouble at all fitting into the
JTabbedPane before data is added.  And the data that is added to it is only
about 30 characters long and has plenty of room to fit into the JList but the
JList (before I used JTabbedPane) used to expand/resize to the left as I
mentioned previously and the data that would be listed would have a lot of
whitespace to the right of each entry.  I tested to see if this whitespace
was actually part of the data by printing the data to the screen and adding
another character to the output and the character appeared right after my
real data so I knew there wasn't any hidden whitespace in my entry data. I
guess the problem of the layout position of the Jlist changing is due to the
size changing so the real problem is figuring out why the JList's size
changes in the first place, especially when it doesn't seem like to me that
it needs to.

> >I
> >consider this worse than previously without the jtabbedpane since I
[quoted text clipped - 7 lines]
> 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

I tried boxlayout. I can't remember what happened when I used it but it
wasn't what I wanted. I may have ended up with lots of spacing around my text
labels (if I'm remembering correctly) still, which was what I was trying to
fix.

> 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
Brandon McCombs - 26 Jul 2005 03:24 GMT
> >hello,
> >
[quoted text clipped - 28 lines]
>
> Pete Barrett

Just wanted to say I fixed the problem myself.  It seems in my infinite
genius I had the JList added to 2 different JScrollPanes and not only that,
but I was adding the JList itself (and not even either one of the
scrollPanes) to the JPanel.  I removed a scrollpane (obviously unneeded) and
modified the JPanel add method's argument to be the leftover scrollpane and
not the JList and now the JList doesn't shift in size.

thanks for your help Pete.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.