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 / General / January 2006

Tip: Looking for answers? Try searching our database.

JLIST - Scrollpane woes

Thread view: 
Kurt M Peters - 28 Jan 2006 14:06 GMT
I am having a problem getting a JList to scroll.
 I am using an extension of AbstractListModel at a model in a JList:
public class TreeSetListModel extends AbstractListModel {
   private Set<String> treeSetList;
   /** Creates a new instance of TreeSetListModel */
   public TreeSetListModel(Set<String> inSet) {
       treeSetList = inSet;
   }
...
}

For the life of me, I cannot get the vertical scrollbar to scroll.  The
horizontal one does (which actually is useless).  Does anyone have any ideas
what I'm going wrong?  Please see comments and code handling the guilty
objects below:

       jSPListNodes = new JScrollPane(JListNodes);
       JListNodes = new javax.swing.JList();

       jSPListNodes = new JScrollPane(JListNodes);
       jSPListNodes.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
       jSPListNodes.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
       jSPListNodes.setAutoscrolls(true);
       jSPListNodes.setMaximumSize(new java.awt.Dimension(48, 48));
       jSPListNodes.setPreferredSize(new java.awt.Dimension(48, 48));
       jSPListNodes.setViewportView(JListNodes);

       jPNodeComponentSelections.add(jSPListNodes,
java.awt.BorderLayout.WEST);
       JListNodes.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
       JListNodes.setFixedCellHeight(48);
       JListNodes.setMaximumSize(new java.awt.Dimension(264, 264));
       JListNodes.setMinimumSize(new java.awt.Dimension(52, 70));
       JListNodes.setPreferredSize(new java.awt.Dimension(52, 80));
       JListNodes.setVisibleRowCount(2);
// after creating and filling a TreeSet, I put it in the List
      JListNodes.setModel(new TreeSetListModel(nodeSet));
//I even tried to revalidate, which doesn't seem to work:

        JListNodes.revalidate();
       jPNodeComponentSelections.revalidate();
       jSPListNodes.revalidate();

Thanks in advance,
Kurt
Andrey Kuznetsov - 28 Jan 2006 20:10 GMT
>        JListNodes.setMaximumSize(new java.awt.Dimension(264, 264));
>        JListNodes.setMinimumSize(new java.awt.Dimension(52, 70));
>        JListNodes.setPreferredSize(new java.awt.Dimension(52, 80));

don't set preferredSize.

Signature

Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

Stefan Ram - 28 Jan 2006 20:15 GMT
>>JListNodes.setPreferredSize(new java.awt.Dimension(52, 80));
>don't set preferredSize.

 Could someone please explain why not?
Andrey Kuznetsov - 28 Jan 2006 20:42 GMT
>>>JListNodes.setPreferredSize(new java.awt.Dimension(52, 80));
>>don't set preferredSize.
>
>  Could someone please explain why not?

because preferred size is used by JScrollPane's (or may be JVievport's)
LayoutManager.
If preferred size set explicitly, then JList's size is no more changed
according to its requrements.

Signature

Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

Kurt M Peters - 28 Jan 2006 23:30 GMT
Thanks, I will give it a try.  I probably will have to do some special
"manuevering" with Netbeans to NOT set prefered size.  Does anyone have any
hints on how to reset prefered size to "not be set" in Netbeans?

Regards,
Kurt
>>        JListNodes.setMaximumSize(new java.awt.Dimension(264, 264));
>>        JListNodes.setMinimumSize(new java.awt.Dimension(52, 70));
>>        JListNodes.setPreferredSize(new java.awt.Dimension(52, 80));
>
> don't set preferredSize.


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



©2009 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.