Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
JTree と TreeModel を使用して表示したいオブジェクトの階層があります。階層の各レベルは異なるクラスです。
私が見た JTree と TreeModel のすべての例には、ツリーの階層全体にわたって共通のクラスがあります (つまり、ファイル システム ブラウザの File)。階層がレベルごとにクラスを変更する場合、TreeModel をどのように実装しますか? TreeModel を TreeModel の中に入れますか?
TreeModel を実装してから、メソッドの独自の実装を提供します。JTree はオブジェクトで動作するため、複数の型を使用しても問題ありません。