Radiobuttons in JTable
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Radiobuttons in JTable

  1. #1
    Join Date
    May 2003
    Posts
    1

    Radiobuttons in JTable

    Hi there,

    I would like to implement a table where the first column is a Radiobutton that serves as a GroupSelector. The second and third column would be a list of names and a checkbox. The idea is to first select a group (say animals, humans) via the radiobuttons, and then within that group use the checkboxes to select individuals in that group (say dogs and cats). When one group is selected, the other group should not be editable (checkboxes disabled).
    I tried to use a double JTable. The First one with 2 cols, where the second col is another JTable with the names and checkboxes. However, I had trouble selecting the checkboxes that way.

    Another idea was to have a radiobutton per row, and hide and disable the ones that are in the same group.

    A third idea was to just one table, and put the names/checkboxes in a panel (one per group) and add them to the respec. columns.

    None of this seems to really be the greatest solution and I had trouble implementing it.

    Does anybody have a better idea?

    Thanks, John.

  2. #2
    Join Date
    Mar 2001
    Location
    Temecula, California
    Posts
    38
    How about two JLists and a JTable. The first JList would list groups, and be set to a SINGLE_SELECTION_MODE. The second JList would be dynamic (allowing multiple selection), showing only members of the group chosen in the first JList (via a ListSelectionListener). Finally, a JTable would capture the state of the lists at the click of a JButton. After a few clicks, the table might look like:

    Group...........Names
    --------.......---------------
    Color...........Red, Blue, Green
    Animals........Dog, Cat
    Color...........Yellow, Black
    Humans........Dave, George, Joey

    Maybe not as elegant as you described, but it would be easy to implement, and user friendly.

    Then again, I might have misunderstood your intent!

    Robin

  3. #3
    Join Date
    Mar 2003
    Location
    switzerland
    Posts
    41

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center