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.
我正在制作某种带有实时日志的控制面板。实时日志应该显示最近 15 次登录。如果有超过 15 条记录,那么我希望删除最后一条记录,并将最近发生的记录显示在列表顶部。如果发生登录或注销,我将使用观察者更新日志列表。我应该使用 Queue 数组还是可以使用 swing 来实现?如果可能,那怎么做?提前致谢。
我认为您应该使用此方法setVisibleRowCount(int visibleRowCount)来设置 Jlist 中可以显示的首选行数。
setVisibleRowCount(int visibleRowCount)
当然。制作您自己的 Tablemodel,可能源自javax.swing.table.AbstractTableModel
只需确保您的模型只公开 15 行(也许使用 aLinkedList<>来保存您的日志条目)。
LinkedList<>