class TopView : View("My View") { val imgFilter:ImageFiltering by inject() lateinit var src:Image override val root = hbox { button("選擇圖片") { action { val efset = arrayOf(FileChooser.ExtensionFilter("圖片文件","*.png", "*.jpg", "*.gif")) val fnset = chooseFile("選擇圖片文件", efset, FileChooserMode.Single) { // p初始目錄爲當前項目目錄 initialDirectory = File(File("").canonicalPath) } if (fnset.isNotEmpty()) { src=Image(File(fnset.first().toString()).inputStream()) val imgv=ImageView(src) imgv.fitWidth=300.0 imgv.fitHeight=300.0 imgFilter.ap.add(imgv) } } } } }
class ImageFiltering : View() { lateinit var ap: FlowPane override val root = scrollpane{ ap = flowpane{ vgap=10.0 hgap=10.0 prefHeight=600.0 prefWidth=800.0 } } }