Combining different components together especially JTree with other components, for example, JButton、JPanel、etc. Sun posts tutorials that can solve these problems. Solution comes in the class of TreeCellRenderer.
But firstly, programmers have to study two different parts:
Swing(http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html) & Renderers/Editors(http://java.sun.com/docs/books/tutorial/2d/overview/rendering.html;
http://java.sun.com/docs/books/tutorial/uiswing/examples/components/index.html; — TableDialogEditDemo; http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#editrender)
relative threads in swing forum
Tutorial is relatively too short comparing to the amount of questions on renderer/editor(more than) . Some “How to” FAQ should be necessary. But I think that is enough for “JButton JTree TreeCellRenderer”.
Most questions are posted by novices and simply want to know how to add a button(or other widgets) as TreeIcon.
Key Words Search:
<renderer JTree JButton>
http://forums.sun.com/thread.jspa?forumID=257&threadID=218278 **
http://forums.sun.com/thread.jspa?forumID=257&threadID=412114 **
http://forums.sun.com/thread.jspa?forumID=57&threadID=597210
http://forums.sun.com/thread.jspa?forumID=257&threadID=335899 **
http://forums.sun.com/thread.jspa?forumID=257&threadID=151706
http://forums.sun.com/thread.jspa?forumID=57&threadID=5214405 —- viable start-up solution included
http://forums.sun.com/thread.jspa?forumID=57&threadID=5172697
http://forums.sun.com/thread.jspa?forumID=57&threadID=5393367
http://forums.sun.com/thread.jspa?forumID=57&threadID=5258666 —-Study about TreeCellEditor, which is similar to Renderer u have used Rederres play the part only in painting tree cells, only editors can catch the button events.
http://forums.sun.com/thread.jspa?forumID=57&threadID=5330659 —- Add JTree in a JTable column
http://forums.sun.com/thread.jspa?forumID=257&threadID=150832 —- Add JTextField to JLabel
http://forums.sun.com/thread.jspa?forumID=256&threadID=393371 ** – Add Usable JComponents(JCheckbox) into JTrees; Viable solution included(http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=2&t=001095)
<TreeCellRenderer JButton>
http://forums.sun.com/thread.jspa?forumID=57&threadID=5364673 **
http://forums.sun.com/thread.jspa?forumID=257&threadID=323978
http://forums.sun.com/thread.jspa?forumID=57&threadID=5308113 **
http://forums.sun.com/thread.jspa?forumID=257&threadID=187869
http://forums.sun.com/thread.jspa?forumID=256&threadID=490627
<Renderer Editor>
…….
This topic are no longer asked now. After a 3 years period, some viable SSCCE can help most beginners start up. It is not only a subject of JButton but also all the JComponents combining with each other.
So these are similar questions about the same underlying design problem.
What makes the SSCCE better in helping beginners than the relevant sections in swing tutorial? Please try to answer this question.
An SSCCE should teach how to assemble all the widgets together. Studying swing tutorial is a good way to promote programming skill but an intuitive code can make a beginner start up more smoothly. In addition, those who asked these kind of questions possibly don’t know what section they should read in tutorials. While some reply told them learn about TreeCellRenderer or Editor, how could they know what to do with this class? A viable example could possibly shows how to use Renderer/Editor in proper ways.
This topic is a typical global knowledge, which programmers frequently faced and asked.