-
Notifications
You must be signed in to change notification settings - Fork 0
Utilities
Thosea edited this page Jun 22, 2025
·
1 revision
KSwing also has some general-purpose Swing utilities.
These allow you to change how big a component should be. These methods are provided:
-
kCapSize/kCapWidth/kCapHeight- changesmaximumSize -
kCapSizeToPreferred/kCapWidthToPreferred/kCapHeightToPreferred- changesmaximumSizepartially or entirely topreferredSize. useful on layouts that let a component span its entire maximum size -
kPreferSize- changespreferredSize
For slightly easier font editing, these properties (also as builder functions) are provided:
kFontSizekBoldkItalickFontName-
kFontAttr(function-only)
Example:
KLabel("Hi There") {
kFontSize = 22f
kBold = true
kFontName = "Comic Sans MS"
kFontAttr(TextAttribute.UNDERLINE to TextAttribute.UNDERLINE_ON)
}
// or
KLabel("Hi There").kFontSize(22f).kBold(true)-
kRevalidateAndRepaint- shortcut forrevalidateandrepaint -
kDocChangeListener(extension ofDocument) - adds a listener that is invoked when any part of the document changes in any way
val state = KState<String>() // nullable
KLazyTextField {
document.kDocChangeListener {
state.value = text
}
}-
KConstantshaskEmptyBorderandkEmptyColor -
KPropertieswraps some Swing/AWT system properties for convenience (i.e.KProperties.useOpengl = true) -
kBagConstraints(...)is a wrapper forGridBagConstraintsusing default parameters -
kImageFromIcon/kBufferImageFromIcongets anImagefrom anIcon