All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dev.robocode.tankroyale.gui.ui.newbattle.AbstractListCellRenderer.kt Maven / Gradle / Ivy

package dev.robocode.tankroyale.gui.ui.newbattle

import java.awt.Component
import javax.swing.JLabel
import javax.swing.JList
import javax.swing.ListCellRenderer
import javax.swing.border.EmptyBorder

abstract class AbstractListCellRenderer : JLabel(), ListCellRenderer {
    init {
        isOpaque = true
    }

    override fun getListCellRendererComponent(
        list: JList?,
        value: Any?,
        index: Int,
        isSelected: Boolean,
        cellHasFocus: Boolean
    ): Component {
        border = EmptyBorder(1, 1, 1, 1)

        if (list != null) {
            if (isSelected) {
                background = list.selectionBackground
                foreground = list.selectionForeground
            } else {
                background = list.background
                foreground = list.foreground
            }
            font = list.font
        }
        onRender(list, value, index, isSelected, cellHasFocus)

        return this
    }

    abstract fun onRender(list: JList?, value: Any?, index: Int, isSelected: Boolean, cellHasFocus: Boolean)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy