How to present a hierarchical String list with checkboxes in Java Swing?

1.1k views Asked by At

So. The ideas have been a few.. no good ones.. So here is the problem i have incountered and can not figure out a solution for.

I need to have a txt file containing a hierarchical list of things to do, looking something like this:

  • Ask a question
    • Before question asked, check similar questions
    • Formulate the question so that the problem is clearly shown.
  • Post the question
    • Hold your thumbs that this might save your day.

The txt file should in the program fill a list shown in a JPanel and after each step have a checkbox to comfirm "I have been a good boy and done this". The list can change over time and grow and shrink, so the solution needs a scrollbar. The list should also contaion a capability to show more the one row.

The solution im working on is done in Jave compiler 1.6 and im using Swing for my layout. Ideas i have had so far are: Modified JTable... and the other solutions i am asshamed of.. And thats about it.. ..

4

There are 4 answers

0
StanislavL On BEST ANSWER

JTree with custom renderer. The renderer should be a panle with checkbox and text area.

1
mKorbel On
0
trashgod On

Also consider org.netbeans.swing.outline.Outline, discussed here and illustrated below. It's not apparent in the screenshot, but the the Outline instance has been added to a JScrollPane.

image

2
Renat Gilmanov On

I would say JTreeTable is a right choice. It will provide a lot of power and flexibility. Please see some very basic examples:

For any serious purpose please use a mature implementation provided, for example, by a SwingLab project:

Please also see the following answer: