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コンポーネントの行を太字にする必要があります。ユーザーがアクティブな行の変更をすぐに確認できるように、動的に実行する必要があります。これどうやってするの?
レンダラーで CustomCellRenderer を見てください。 isSelected 引数に基づいて、表示されたラベルの色を変更できます。
選択したアイテムの色を変更したい場合に備えて、次を使用できます。
list.setSelectionForeground(Color.RED);
選択したアイテムの背景を設定するための別の同様の API があります。
list.setSelectionBackground(Color.BLUE);