新建scala工程并导出jar运行
发布日期:2021-10-10 05:30:56 浏览次数:27 分类:技术文章

本文共 1089 字,大约阅读时间需要 3 分钟。

1.新建Scala Project,这里我们命名为test

2.导入库

3.新建包以及新建Scala Object,这里我们命名为test.scala

4.敲代码

package com.hunauimport scala.swing.SimpleSwingApplication  import scala.swing.FileChooser  import java.io.File  import scala.swing.MainFrame  import scala.swing.FlowPanel  import scala.swing.Button  import scala.swing.Label  import scala.swing.event.ButtonClicked      object test extends SimpleSwingApplication {        val fileChooser = new FileChooser(new File(".")) //文件对话框    fileChooser.title = "选择文件"    val button = new Button{      text = "从本地选择文件"    }    val label = new Label {      text = "还未选择文件."    }    val mainPanel = new FlowPanel{      contents += button      contents += label    }        def top = new MainFrame{      title = "Scala GUI编程 !!!"      contents = mainPanel            listenTo(button)            reactions += {        case ButtonClicked(b) => {          val result = fileChooser.showOpenDialog(mainPanel)          if(result == FileChooser.Result.Approve){            label.text = fileChooser.selectedFile.getPath()          }        }      }    }      }

5.导出jar

6.打开终端,运行

转载地址:https://blog.csdn.net/qq_22042587/article/details/72773381 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:linux驱动学习记录(一)-字符设备框架
下一篇:安卓端APP遥控树莓派小车

发表评论

最新留言

很好
[***.229.124.182]2024年04月21日 03时02分18秒