Skip to content

Commit a01fea5

Browse files
authored
Merge pull request #124 from Sciss/dotty
Dotty 3.0.0-M1 support
2 parents 7bf1a24 + c7e089b commit a01fea5

35 files changed

+279
-269
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ scala-swing.iml
3030
.DS_Store
3131

3232
target/
33+
/.bloop/
34+
/.bsp/

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ scala:
88
- 2.11.12
99
- 2.12.11
1010
- 2.13.3
11+
- 3.0.0-M1
1112

1213
env:
1314
- ADOPTOPENJDK=8

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
[<img src="https://img.shields.io/maven-central/v/org.scala-lang.modules/scala-swing_2.12.svg?label=latest%20release%20for%202.12"/>](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.scala-lang.modules%20a%3Ascala-swing_2.12)
66
[<img src="https://img.shields.io/maven-central/v/org.scala-lang.modules/scala-swing_2.13.svg?label=latest%20release%20for%202.13"/>](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.scala-lang.modules%20a%3Ascala-swing_2.13)
77

8-
This is now community maintained by [@Sciss](https://github.com/Sciss) and [@benhutchison](https://github.com/benhutchison). If you are interested in helping then contact them or [@adriaanm](https://github.com/adriaanm).
8+
This is now community maintained by [@Sciss](https://github.com/Sciss) and [@benhutchison](https://github.com/benhutchison).
9+
If you are interested in helping then contact them or [@adriaanm](https://github.com/adriaanm).
910

1011
## Adding an sbt dependency
1112

1213
To use scala-swing from sbt, add this to your `build.sbt`:
1314

1415
```
15-
libraryDependencies += "org.scala-lang.modules" %% "scala-swing" % "2.1.1"
16+
libraryDependencies += "org.scala-lang.modules" %% "scala-swing" % "3.0.0"
1617
```
1718

1819
## About scala-swing
@@ -113,6 +114,7 @@ new Frame {
113114
- When using Scala 2.11, you can use the Scala swing 2.0.x releases on JDK 6 or newer.
114115
- Scala 2.12 requires you to use JDK 8 (that has nothing to do with scala-swing).
115116
- The `2.1.x` series adds support for Scala 2.13, while dropping Scala 2.10.
117+
- The `3.0.x` series adds support for Scala 3.0.
116118

117119
The reason to have different major versions is to allow for binary incompatible changes. Also, some java-swing classes were
118120
generified in JDK 7 (see [SI-3634](https://issues.scala-lang.org/browse/SI-3634)) and require the scala-swing sources to be adjusted.

build.sbt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
1+
lazy val scalaTestVersion = "3.2.3"
2+
3+
lazy val commonSettings = Seq(
4+
crossScalaVersions := Seq("3.0.0-M1", "2.13.3", "2.12.12", "2.11.12"),
5+
scalaVersion := "2.13.3",
6+
scalacOptions ++= Seq("-deprecation", "-feature"),
7+
)
8+
19
lazy val swing = project.in(file("."))
210
.settings(ScalaModulePlugin.scalaModuleSettings)
311
.settings(ScalaModulePlugin.scalaModuleOsgiSettings)
12+
.settings(commonSettings)
413
.settings(
514
name := "scala-swing",
615
OsgiKeys.exportPackage := Seq(s"scala.swing.*;version=${version.value}"),
716
scalaModuleMimaPreviousVersion := Some("2.1.0"),
817
// set the prompt (for this build) to include the project id.
918
ThisBuild / shellPrompt := { state => Project.extract(state).currentRef.project + "> " },
1019
libraryDependencies ++= Seq(
11-
"org.scalatest" %% "scalatest-flatspec" % "3.2.0" % Test,
12-
"org.scalatest" %% "scalatest-shouldmatchers" % "3.2.0" % Test,
20+
"org.scalatest" %% "scalatest-flatspec" % scalaTestVersion % Test,
21+
"org.scalatest" %% "scalatest-shouldmatchers" % scalaTestVersion % Test,
1322
),
1423
// Adds a `src/main/scala-2.13+` source directory for Scala 2.13 and newer
1524
// and a `src/main/scala-2.13-` source directory for Scala version older than 2.13
1625
Compile / unmanagedSourceDirectories += {
1726
val sourceDir = (Compile / sourceDirectory).value
1827
CrossVersion.partialVersion(scalaVersion.value) match {
1928
case Some((2, n)) if n >= 13 => sourceDir / "scala-2.13+"
29+
case Some((3, _)) => sourceDir / "scala-2.13+" // Dotty
2030
case _ => sourceDir / "scala-2.13-"
2131
}
2232
}
2333
)
2434

2535
lazy val examples = project.in(file("examples"))
2636
.dependsOn(swing)
37+
.settings(commonSettings)
2738
.settings(
2839
scalaVersion := (swing / scalaVersion).value,
2940
run / fork := true,
@@ -32,6 +43,7 @@ lazy val examples = project.in(file("examples"))
3243

3344
lazy val uitest = project.in(file("uitest"))
3445
.dependsOn(swing)
46+
.settings(commonSettings)
3547
.settings(
3648
scalaVersion := (swing / scalaVersion).value,
3749
run / fork := true,

examples/src/main/scala/scala/swing/examples/LinePainting.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ object LinePainting extends SimpleSwingApplication {
4747
var path = new geom.GeneralPath
4848

4949
def lineTo(p: Point): Unit = {
50-
path.lineTo(p.x, p.y); repaint()
50+
path.lineTo(p.x.toFloat, p.y.toFloat); repaint()
5151
}
5252

5353
def moveTo(p: Point): Unit = {
54-
path.moveTo(p.x, p.y); repaint()
54+
path.moveTo(p.x.toFloat, p.y.toFloat); repaint()
5555
}
5656

5757
override def paintComponent(g: Graphics2D): Unit = {

examples/src/main/scala/scala/swing/examples/tutorials/components/ButtonHtmlDemo.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,19 @@ class ButtonHtmlDemo extends FlowPanel {
8888
listenTo(enable)
8989

9090
reactions += {
91-
case ButtonClicked(`enable`) => enableMiddle
92-
case ButtonClicked(`disable`) => disableMiddle
91+
case ButtonClicked(`enable`) => enableMiddle()
92+
case ButtonClicked(`disable`) => disableMiddle()
9393
}
9494

9595
def enableMiddle(): Unit = {
96-
enable.enabled = false
97-
middle.enabled = true
98-
disable.enabled = true
96+
enable .enabled = false
97+
middle .enabled = true
98+
disable .enabled = true
9999
}
100100
def disableMiddle(): Unit = {
101-
enable.enabled = true
102-
middle.enabled = false
103-
disable.enabled = false
101+
enable .enabled = true
102+
middle .enabled = false
103+
disable .enabled = false
104104
}
105105
def createImageIcon(path: String): Option[javax.swing.ImageIcon] = {
106106
val imgURL: java.net.URL = getClass().getResource(path)

0 commit comments

Comments
 (0)