1

申し訳ありませんが、MCVE を提供できません。すでに解決策を見つけましたが、問題が発生する理由を理解したいと思います。
カスタム (サードパーティ) テーマで Syntetica L&F を使用しています。バグはこの L&F だけです。JIDEのOffice L&Fでは再現できません。

私は次のコードを持っていますDefaultListCellRenderer

    /**
     * {@inheritDoc}
     */
    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index,
            boolean isSelected, boolean cellHasFocus) {
        super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        //
        // extract text and icon from my business object
        // do nothing with colors
        //
        // here is new code which I added as I got my problem
        //
        if (isSelected) {
            final Color c = list.getSelectionForeground();
            System.out.println("color: " + c + " // " + c.getAlpha() + " // " + c.getTransparency());
            setForeground(c);
        }
        return this;
    }

print ステートメントの出力は次のとおりです。

color: javax.swing.plaf.ColorUIResource[r=255,g=255,b=255] // 255 // 1

しかし、選択した行の前景が黒くなります(間違っています)ステートメント
の最後の行を次のように変更すると:if

setForeground(new Color(c.getRGB()));

選択した行の正しい白い前景を取得します。

誰かがこの動作を説明できますか?

更新: Synth L&F または Synthetica L&F のバグのようです。上記の行を次のように変更すると

setForeground(new ColorUIResource(Color.WHITE));

再び黒の前景を取得します。

4

0 に答える 0