{"id":28399877,"url":"https://github.com/scala/scala-swing","last_synced_at":"2025-06-28T21:31:45.058Z","repository":{"id":12262924,"uuid":"14881281","full_name":"scala/scala-swing","owner":"scala","description":"Scala wrappers for Java's Swing API for desktop GUIs","archived":false,"fork":false,"pushed_at":"2025-06-10T05:08:37.000Z","size":2223,"stargazers_count":136,"open_issues_count":21,"forks_count":47,"subscribers_count":27,"default_branch":"work","last_synced_at":"2025-06-10T06:20:54.570Z","etag":null,"topics":["desktop","gui","scala","swing"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scala.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2013-12-03T02:30:09.000Z","updated_at":"2025-06-10T05:08:41.000Z","dependencies_parsed_at":"2024-06-20T01:26:09.386Z","dependency_job_id":"3c8e63ea-1827-44aa-a8d0-ddba6c5eabff","html_url":"https://github.com/scala/scala-swing","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/scala/scala-swing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scala%2Fscala-swing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scala%2Fscala-swing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scala%2Fscala-swing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scala%2Fscala-swing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scala","download_url":"https://codeload.github.com/scala/scala-swing/tar.gz/refs/heads/work","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scala%2Fscala-swing/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262502304,"owners_count":23321121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["desktop","gui","scala","swing"],"created_at":"2025-06-01T08:11:32.594Z","updated_at":"2025-06-28T21:31:45.051Z","avatar_url":"https://github.com/scala.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# scala-swing\n\n[![build](https://github.com/scala/scala-swing/workflows/test/badge.svg)](https://github.com/scala/scala-swing/actions/workflows/ci.yml?query=branch%3Awork)\n[\u003cimg src=\"https://img.shields.io/maven-central/v/org.scala-lang.modules/scala-swing_2.11.svg?label=latest%20release%20for%202.11\"/\u003e](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.scala-lang.modules%20a%3Ascala-swing_2.11)\n[\u003cimg src=\"https://img.shields.io/maven-central/v/org.scala-lang.modules/scala-swing_2.12.svg?label=latest%20release%20for%202.12\"/\u003e](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.scala-lang.modules%20a%3Ascala-swing_2.12)\n[\u003cimg src=\"https://img.shields.io/maven-central/v/org.scala-lang.modules/scala-swing_2.13.svg?label=latest%20release%20for%202.13\"/\u003e](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.scala-lang.modules%20a%3Ascala-swing_2.13)\n\n## Maintenance status\n\nScala-swing is community-maintained by [@Sciss](https://github.com/Sciss) and [@benhutchison](https://github.com/benhutchison), with an occasional assist from [@SethTisue](https://github.com/SethTisue). If you are interested in helping, then start a thread in the [Discussions section](https://github.com/scala/scala-swing/discussions), or contact the maintainers.\n\n## Adding an sbt dependency\n\nTo use scala-swing from sbt, add this to your `build.sbt`:\n\n```\nlibraryDependencies += \"org.scala-lang.modules\" %% \"scala-swing\" % \"3.0.0\"\n```\n\n## About scala-swing\n\nThis is a UI library that wraps most of Java Swing for Scala in a straightforward manner. \nThe widget class hierarchy loosely resembles that of Java Swing. The main differences are:\n\n- In Java Swing all components are containers per default. This does not make much sense for\n  a number of components, like TextField, CheckBox, RadioButton, and so on. Our guess is that \n  this architecture was chosen because Java lacks multiple inheritance. \n  In scala-swing, components that can have child components extend the Container trait.\n- Layout managers and panels are coupled. There is no way to exchange the layout manager\n  of a panel. As a result, the layout constraints for widgets can be typed. \n  (Note that you gain more type-safety and do not loose much flexibility here. Besides \n  being not a common operation, exchanging the layout manager of a panel in Java \n  Swing almost always leads to exchanging the layout constraints for every of the panel's \n  child component. In the end, it is not more work to move all children to a newly created \n  panel.)\n- Widget hierarchies are built by adding children to their parent container's `contents`\n  collection. The typical usage style is to create anonymous subclasses of the widgets to\n  customize their properties, and nest children and event reactions.\n- The scala-swing event system follows a different approach than the underlying Java system.\n  Instead of adding event listeners with a particular interface (such as `java.awt.ActionListener`),\n  a `Reactor` instance announces the interest in receiving events by calling `listenTo` for\n  a `Publisher`. Publishers are also reactors and listen to themselves per default as a convenience.\n  A reactor contains an object `reactions` which serves as a convenient place to register observers\n  by adding partial functions that pattern match for any event that the observer is interested in.\n  This is shown in the examples section below.\n- For more details see [SIP-8](docs/SIP-8.md)\n\nThe library comprises two main packages:\n\n- `scala.swing`: All widget classes and traits.\n- `scala.swing.event`: The event hierarchy.\n\n## Examples\n\nA number of examples can be found in the `examples` project. \nA good place to start is `[16] scala.swing.examples.UIDemo`.\nThis pulls in the all the other examples into a tabbed window.\n\n```\n$ sbt examples/run\n\nMultiple main classes detected, select one to run:\n\n [1] scala.swing.examples.ButtonApp\n [2] scala.swing.examples.CelsiusConverter\n [3] scala.swing.examples.CelsiusConverter2\n [4] scala.swing.examples.ColorChooserDemo\n [5] scala.swing.examples.ComboBoxes\n [6] scala.swing.examples.CountButton\n [7] scala.swing.examples.Dialogs\n [8] scala.swing.examples.GridBagDemo\n [9] scala.swing.examples.HelloWorld\n [10] scala.swing.examples.LabelTest\n [11] scala.swing.examples.LinePainting\n [12] scala.swing.examples.ListViewDemo\n [13] scala.swing.examples.PopupDemo\n [14] scala.swing.examples.SwingApp\n [15] scala.swing.examples.TableSelection\n [16] scala.swing.examples.UIDemo\n\nEnter number:\n```\n\n### Frame with a Button\n\nThe following example shows how to plug components and containers together and react to a\nmouse click on a button:\n\n```scala\nimport scala.swing._\n\nnew Frame {\n  title = \"Hello world\"\n  \n  contents = new FlowPanel {\n    contents += new Label(\"Launch rainbows:\")\n    contents += new Button(\"Click me\") {\n      reactions += {\n        case event.ButtonClicked(_) =\u003e\n          println(\"All the colours!\")\n      }\n    }\n  }\n  \n  pack()\n  centerOnScreen()\n  open()\n}\n```\n\n## Versions\n  \n- The `1.0.x` branch is compiled with JDK 6 and released for Scala 2.11 and 2.11. The 1.0.x releases can be used with both Scala versions on JDK 6 or newer.\n- The `2.0.x` branch is compiled with JDK 8 and released for Scala 2.11 and 2.12.\n  - When using Scala 2.11, you can use the Scala swing 2.0.x releases on JDK 6 or newer.\n  - Scala 2.12 requires you to use JDK 8 (that has nothing to do with scala-swing).\n- The `2.1.x` series adds support for Scala 2.13, while dropping Scala 2.10.\n- The `3.0.x` series adds support for Scala 3.0.\n\nThe reason to have different major versions is to allow for binary incompatible changes. Also, some java-swing classes were \ngenerified in JDK 7 (see [SI-3634](https://issues.scala-lang.org/browse/SI-3634)) and require the scala-swing sources to be adjusted.\n\nVersions now follow classic Scala PVP style with binary compatibility within `x.y.*` but not `x.*.*`.\n\n## API documentation (Scaladoc)\n\nThe API documentation for scala-swing can be found\nat \u003chttps://javadoc.io/doc/org.scala-lang.modules/scala-swing_2.13/latest/index.html\u003e for scala 2.13 and\n\u003chttps://javadoc.io/doc/org.scala-lang.modules/scala-swing_3/latest/index.html\u003e for scala 3.\n\n\n## Current Work\n\nCurrent changes are being made on the `work` branch.\nLast published version is found on the `main` branch.\n\n## Publishing New Versions\n\nWe assume that you are working on a fork of remote `upstream`  with remote `origin`.\n\n- create a new local branch that will never be pushed remotely, e.g. `git checkout -b release-3.0.0#3.0.0-RC2`\n  (do not name the branch the same as a tag)\n- edit `.travis.yml` to reduce the matrix to only the Scala and JDK versions needed to publish the version\n  (publishing JDK is 8)\n- `git commit`\n- add a tag, e.g. `git tag -a 'v3.0.0#3.0.0-RC2' -m 'version 3.0.0 for 3.0.0-RC2'`\n- push __only the tag__, e.g. `git push upstream v3.0.0#3.0.0-RC2`.\n- check CI status at [https://travis-ci.com/github/scala/scala-swing](https://travis-ci.com/github/scala/scala-swing).\n  You should see a message `Running ci-release.` followed by e.g `published scala-swing_3.0.0-RC2 to ...` going into\n  local `sonatype-staging`, followed by the Sonatype plugin uploading the artifacts.\n- Upon success, nudge Seth to release the bundle from Sonatype.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscala%2Fscala-swing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscala%2Fscala-swing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscala%2Fscala-swing/lists"}