• Post Reply Bookmark Topic Watch Topic
  • New Topic

Jlist question  RSS feed

 
Hasnain S
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have six Jlists in parallel in a gridlayout panel

centerPanel2.setLayout(new GridLayout(1, 0, 24, 0));
centerPanel2.add(jScrollPane0, 0);
centerPanel2.add(jScrollPane1, 1);
centerPanel2.add(jScrollPane2, 2);
centerPanel2.add(jScrollPane3, 3);
centerPanel2.add(jScrollPane4, 4);
centerPanel2.add(jScrollPane5, 5);

all six of them ar equall in width

is there a way to change the width of each list.

i am using the defaultlistmodel for the jlists
 
Hasnain S
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the setsize mthod in the defaultlistmodel doesnt seem to effect the lists
 
Hasnain S
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok maybe it means the 'size' aka elements

anyway

plz help
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really don't know what you're asking here.

GridLayout sizing is such that all widths are as wide as the widest component,
likewise for heights.

You are adding scrollpanes to the 'centerPanel', so the size of the JList/s,
within their scrollpane, is irrelevant.

what is it, exactly, you are trying to do.
 
Hasnain S
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it opkay for me to post the code here

coz its really big

im trying to create a table like window, but instead of using JTable i have like six Jlists in parallel....the problem is that they are all the same width...which i figured is becoz of GridLayout...which sizes all the components by itself

i have two lists like city and name....i want the name list to be wider than the city list

i know GridBagLayout will do the trick...but when i use it i get really small square JLists in the centerPanel
 
Hasnain S
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the problem is with the grid bag constants...so if u could post a sample code for me for two lists(only the contants part)...that would help
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> so if u could post a sample code for me for two lists

it would be much better for you to post a sample code, then we can just
add the extra line or two.

any reason you can't use a JTable?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!