Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JList

 
Vu Pham
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the image .

http://s6.yousendit.com/d.aspx?id=031LTMCYSMRHB3KJYCY9O8TGUU

Then , I maximized the window . Here is the image .

http://s13.yousendit.com/d.aspx?id=32EFQ8U3AMJP72VXD4FKBQJFCN

I dont want that JList changed like that . Please help me . I want JList's size isn't changed .
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you want the JList to be left half of the frame, set the frame as a
gridlayout 1 row 2 colums, and add the scrollpane(containing the JList)
directly to the frame. it will then occupy the left half of whatever size
the frame is.

something like this

 
Pat Hays
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anh Vu

You only need to add one code, please see below:

-------------
jScrollPane1.setPreferredSize(new Dimension(150, 20)); //Note: The jScrollPane1 is the perent of the JList. Set its preferred width to be 150, or whatever you prefer.
 
Vu Pham
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried many layouts and I have set "setPreferedSize()" to many components which are parent of JList . But now I still cant solve my problem .
Here is the image before

http://s36.yousendit.com/d.aspx?id=3104DKKVJZ5WS1GMEYYMCYPFBT

and then

http://s36.yousendit.com/d.aspx?id=1IFQPH405MWQ80KB3TYRZKDA9M
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
perhaps you should post your code, just the GUI shell - enough to
demonstrate the problem.
 
Vu Pham
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I have solved my problem . Just "setPreferedSize()" . Thanks all .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic