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 / GUI / March 2005

Tip: Looking for answers? Try searching our database.

Checkbox list in a scroll pane

Thread view: 
Sonia gun - 09 Mar 2005 21:18 GMT
Hi,

In my application, I have a JList . Items of JList are checkboxes (not the
usual labels. This JList is on a JScrollPane.

JCheckBox - on - JList - on - JScrollPane - on - JPanel

I implemented the listmodel so that the list can get events about any
changes to the list. I also have a custom cellrenderer to provide
checkboxes instead of just the Jlabels to the list. When ever anything
changes with the list (contents for example) only the list is updated. Now
the issue is that...sporadically, the list does not get rendered correctly.
The scrollpane is lost even though i have all the items in the list. only
some of the items are visible on the screen. But the visible items are not
click-able (!!??). they just dont take any events.

Any help is greatly appreciated.
John McGrath - 10 Mar 2005 02:08 GMT
> I implemented the listmodel so that the list can get events about any
> changes to the list. I also have a custom cellrenderer to provide
> checkboxes instead of just the Jlabels to the list. When ever anything
> changes with the list (contents for example) only the list is updated.
> Now the issue is that...sporadically, the list does not get rendered
> correctly.  

It is unlikely that anyone will be able to figure out the problem from
this description.  It would be a good idea to post a runnable example of
the problem.

> The scrollpane is lost even though i have all the items in the list.

How is it lost?

> only some of the items are visible on the screen. But the visible
> items are not click-able (!!??). they just dont take any events.

The component supplied by a renderer is not realized.  It is only used by
the JList for rendering, so events will not occur on the renderer.  If the
user clicks "on" the checkbox, he is actually clicking on the JList.  In
order to get the checkbox to appear to work, you will need to:

1) Create a model that stores the "checked" state of the items in the list.
2) Recognize mouse events on the JList,
3) Modify the state of the model in response to the events.
4) Repaint the list cell when the model changes.

Signature

Regards,

John McGrath



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



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