Results 1 to 2 of 2
  1. #1
    dropez is offline Member
    Join Date
    Mar 2009
    Posts
    6
    Rep Power
    0

    Default CheckBox Jlist items

    Hello there.

    I'm very new in developing Swing apps yet i've got a kind of complicated project to develop.
    It would be a big help for my project to have a JList whose items where checkBoxes or any similar component with this behaviour. This component shouldn't have a limit of items since the items displayed depend of the selection in the previous Jlist. I cant seem to find any component like this anywhere.
    Any sugestions?

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    8

    Default

    a JList whose items where checkBoxes
    You can do this by wriing/providing a ListCellRenderer for you list. Both the JList and ListCellRenderer api comments have example code. Also the tutorial page for JList mentions this in the section Writing a Custom Cell Renderer.
    If you want the JCheckBoxes to be editable by the user you would need to also provide an editor. I don't see any provisions for editors in the JList api. So I would try a JTable with a single column and no header. JTable provides support for both cell renderers and cell editors. The tutorial page for JTable use has discussion about these: How to Use Tables.

Similar Threads

  1. [SOLVED] Checkbox new to Java
    By s34nn4 in forum Java Applets
    Replies: 11
    Last Post: 04-12-2009, 05:21 AM
  2. passing object as value for checkbox values??
    By Pooja Deshpande in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 03-17-2009, 11:55 AM
  3. Displaying a price with a checkbox
    By F4iChick02 in forum New To Java
    Replies: 4
    Last Post: 12-09-2008, 05:13 AM
  4. How to use ItemListener for CheckBox class
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 04-23-2008, 08:18 PM
  5. checkbox
    By Alan in forum AWT / Swing
    Replies: 3
    Last Post: 05-18-2007, 10:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •