日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java kotlin lateinit_kotlin - 如何检查“lateinit”变量是否已初始化?

發布時間:2023/12/19 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java kotlin lateinit_kotlin - 如何检查“lateinit”变量是否已初始化? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我想知道是否有辦法檢查lateinit變量是否已初始化。

import javafx.application.Application

import javafx.event.EventHandler

import javafx.geometry.Insets

import javafx.geometry.Pos

import javafx.scene.Scene

import javafx.scene.control.Button

import javafx.scene.control.ComboBox

import javafx.scene.layout.VBox

import javafx.stage.DirectoryChooser

import javafx.stage.Stage

import java.io.File

class SeriesManager() {

lateinit var seriesDir: File

val allSeries by lazy {

seriesDir.listFiles().map { it.name }.toTypedArray()

}

}

class SeriesManagerUI : Application() {

override fun start(primaryStage: Stage) {

val sm = SeriesManager()

val setSeriesDirBtn = Button("Change all series location").apply {

onAction = EventHandler {

sm.seriesDir = DirectoryChooser().apply {

title = "Choose all series location"

}.showDialog(primaryStage)

}

}

val allSeriesList = ComboBox().apply {

promptText = "Select a series from here"

isDisable = // I want this to be always true, unless the SeriesManager.seriesDir has been initialized

}

val setCurrentEpisodeBtn = Button("Change the current episode")

val openNextEpisode = Button("Watch the next episode")

val layout = VBox(

setSeriesDirBtn,

allSeriesList,

setCurrentEpisodeBtn,

openNextEpisode

).apply {

padding = Insets(15.0)

spacing = 10.0

alignment = Pos.CENTER

}

primaryStage.apply {

scene = Scene(layout).apply {

minWidth = 300.0

isResizable = false

}

title = "Series Manager"

}.show()

}

}

fun main(args: Array) {

Application.launch(SeriesManagerUI::class.java, *args)

}

總結

以上是生活随笔為你收集整理的java kotlin lateinit_kotlin - 如何检查“lateinit”变量是否已初始化?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。