新建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 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
很好
[***.229.124.182]2024年04月21日 03时02分18秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
Apache服务器下使用 ab 命令进行压力测试
2019-04-27
查看Firefox中的缓存
2019-04-27
http header头设置反向代理不缓存
2019-04-27
配置MySQL主从复制
2019-04-27
CI框架如何删除地址栏的 index.php
2019-04-27
expires与etag控制页面缓存的优先级
2019-04-27
取消掉Transfer-Encoding:chunked
2019-04-27
HTTP协议中的Tranfer-Encoding:chunked编码解析
2019-04-27
JavaScript面向对象编程
2019-04-27
在Javascript中使用面向对象的编程
2019-04-27
由浅入深剖析.htaccess
2019-04-27
php函数serialize()与unserialize()
2019-04-27
PHP Webservice的发布与调用
2019-04-27
php反射类 ReflectionClass
2019-04-27
php扩展xdebug基本使用
2019-04-27
为 PHP 应用提速、提速、再提速
2019-04-27
Linux下gedit显示行号
2019-04-27
《Advanced PHP Programming》读书笔记
2019-04-27
让我们谈谈RAID
2019-04-27
jQuery日期选择器插件date-input
2019-04-27