• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I want to increase the Jpanel size so that i can fit a bigger Jlist

 
nand rai
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have problem in incresing the size of Jlist so that it can show at least 15 list items.

I have a jpanel which has this jlist. I am using null layout for my panel. how to achive this.

When trying to increse the size of Jlist i thought jpanel will also increse but it is not doing.

Note: when i created the Jpanel i did not mentioned any dimenssions.

I am also attaching the screen shot of the panel.


Note : Can i use any layout to keep my components as it looks in my attachment

Thanks
Jlist.JPG
[Thumbnail for Jlist.JPG]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why didn't you just continue your other thread?

anyway, these steps should work

add the elements to the list's model
set the visible row count
add the list to a scrollpane
get the scrollpane's preferredSize
set the scrollpane's location
set the scrollpane's size as it's preferredSize.width,preferredSize.height
(the above 2 can be combined into setBounds())

this should give you a scrollpane at the correct height, and as wide as it's widest element,
so you may need to add a bit to the width if you want some whitespace showing
 
nand rai
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



//listScrollPane.setBounds(new Rectangle(710, 7, 99, 35)); commented this and changed above as recommended
MultiSelectJList.setBounds(new Rectangle(710, 7, 99, 35)); does this matter?


please let me what else need to be added. I am very new 2 swing. I am using it for the first time in my life.


 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> I am very new 2 swing. I am using it for the first time in my life.

then bookmark this page:

http://java.sun.com/docs/books/tutorial/uiswing/TOC.html

read the tutorials, and the corresponding api documentation of the component/s you are using.
90+% of all swing problems can be resolved by referring to the above docs.

go through the steps (in the specified order) of my first reply, and it works OK (just tested it).

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic