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.
有没有办法改变 JList 上特定元素的文本颜色?
像这样:
一个(黑色)
二(蓝色)
三(黑色)
四(蓝色)
五(蓝色)
六(黑色)
使用 DefaultListModel 并且数据来自数据库...
模型只存储数据,不存储数据的颜色。
您需要为每个单元格以不同的方式呈现数据。阅读 Swing 教程中关于编写自定义渲染器的部分以获取更多信息和示例。