2022-03-19 (土) 11:33:09
  • category: swing folder: FilteredTable title: JTableに行フィルタで表示の切り替え tags: [JTable, DefaultTableModel] author: aterai pubdate: 2005-01-31T07:28:18+09:00 description: JTableに表示する行をフィルタを使用して切り替えます。 image: https://lh5.googleusercontent.com/_9Z4BYR88imo/TQTMpQqDR4I/AAAAAAAAAZg/vitkhyUoKkI/s800/FilteredTable.png

概要

JTableに表示する行をフィルタを使用して切り替えます。
http://terai.s55.xrea.com/swing/filteredtable/screenshot.png

サンプルコード

View in GitHub: Java, Kotlin

解説

  • DefaultTableModelのフィールドにあるdataVectorを表示用に使用し、これとは別にすべての行を保持するVectorを作成
    • 例えば奇数行だけ表示するという条件が選択された場合、この条件に適合する行だけを保持用Vectorから表示用のdataVectorにコピーすることでフィルタリングを実施

参考リンク

コメント