• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Jlist question

 
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
 
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?
 
Get meta with me! What pursues us is our own obsessions! But not this tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!