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

kotlin.swing.Dimensions.kt Maven / Gradle / Ivy

There is a newer version: 0.14.451
Show newest version
package kotlin.swing

import java.awt.Dimension
import java.awt.Component
import javax.swing.JComponent

/**
 * Returns the width of the dimension or zero if its null
 */
fun Dimension?.width(): Int {
    return if (this == null) 0 else this.width
}

/**
 * Returns the height of the dimension or zero if its null
 */
fun Dimension?.height(): Int {
    return if (this == null) 0 else this.height
}

/**
 * Returns a new dimension with the same height and the given width
 */
fun Dimension?.width(newValue: Int): Dimension {
    return Dimension(newValue, height())
}
/**
 * Returns a new dimension with the same width and the given height
 */
fun Dimension?.height(newValue: Int): Dimension {
    return Dimension(width(), newValue)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy