Code Monkey home page Code Monkey logo

scala-swing's Introduction

scala-swing

Maintenance status

Scala-swing is community-maintained by @Sciss and @benhutchison, with an occasional assist from @SethTisue. If you are interested in helping, then start a thread in the Discussions section, or contact the maintainers.

Adding an sbt dependency

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

libraryDependencies += "org.scala-lang.modules" %% "scala-swing" % "3.0.0"

About scala-swing

This is a UI library that wraps most of Java Swing for Scala in a straightforward manner. The widget class hierarchy loosely resembles that of Java Swing. The main differences are:

  • In Java Swing all components are containers per default. This does not make much sense for a number of components, like TextField, CheckBox, RadioButton, and so on. Our guess is that this architecture was chosen because Java lacks multiple inheritance. In scala-swing, components that can have child components extend the Container trait.
  • Layout managers and panels are coupled. There is no way to exchange the layout manager of a panel. As a result, the layout constraints for widgets can be typed. (Note that you gain more type-safety and do not loose much flexibility here. Besides being not a common operation, exchanging the layout manager of a panel in Java Swing almost always leads to exchanging the layout constraints for every of the panel's child component. In the end, it is not more work to move all children to a newly created panel.)
  • Widget hierarchies are built by adding children to their parent container's contents collection. The typical usage style is to create anonymous subclasses of the widgets to customize their properties, and nest children and event reactions.
  • The scala-swing event system follows a different approach than the underlying Java system. Instead of adding event listeners with a particular interface (such as java.awt.ActionListener), a Reactor instance announces the interest in receiving events by calling listenTo for a Publisher. Publishers are also reactors and listen to themselves per default as a convenience. A reactor contains an object reactions which serves as a convenient place to register observers by adding partial functions that pattern match for any event that the observer is interested in. This is shown in the examples section below.
  • For more details see SIP-8

The library comprises two main packages:

  • scala.swing: All widget classes and traits.
  • scala.swing.event: The event hierarchy.

Examples

A number of examples can be found in the examples project. A good place to start is [16] scala.swing.examples.UIDemo. This pulls in the all the other examples into a tabbed window.

$ sbt examples/run

Multiple main classes detected, select one to run:

 [1] scala.swing.examples.ButtonApp
 [2] scala.swing.examples.CelsiusConverter
 [3] scala.swing.examples.CelsiusConverter2
 [4] scala.swing.examples.ColorChooserDemo
 [5] scala.swing.examples.ComboBoxes
 [6] scala.swing.examples.CountButton
 [7] scala.swing.examples.Dialogs
 [8] scala.swing.examples.GridBagDemo
 [9] scala.swing.examples.HelloWorld
 [10] scala.swing.examples.LabelTest
 [11] scala.swing.examples.LinePainting
 [12] scala.swing.examples.ListViewDemo
 [13] scala.swing.examples.PopupDemo
 [14] scala.swing.examples.SwingApp
 [15] scala.swing.examples.TableSelection
 [16] scala.swing.examples.UIDemo

Enter number:

Frame with a Button

The following example shows how to plug components and containers together and react to a mouse click on a button:

import scala.swing._

new Frame {
  title = "Hello world"
  
  contents = new FlowPanel {
    contents += new Label("Launch rainbows:")
    contents += new Button("Click me") {
      reactions += {
        case event.ButtonClicked(_) =>
          println("All the colours!")
      }
    }
  }
  
  pack()
  centerOnScreen()
  open()
}

Versions

  • 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.
  • The 2.0.x branch is compiled with JDK 8 and released for Scala 2.11 and 2.12.
    • When using Scala 2.11, you can use the Scala swing 2.0.x releases on JDK 6 or newer.
    • Scala 2.12 requires you to use JDK 8 (that has nothing to do with scala-swing).
  • The 2.1.x series adds support for Scala 2.13, while dropping Scala 2.10.
  • The 3.0.x series adds support for Scala 3.0.

The reason to have different major versions is to allow for binary incompatible changes. Also, some java-swing classes were generified in JDK 7 (see SI-3634) and require the scala-swing sources to be adjusted.

Versions now follow classic Scala PVP style with binary compatibility within x.y.* but not x.*.*.

API documentation (Scaladoc)

The API documentation for scala-swing can be found at https://javadoc.io/doc/org.scala-lang.modules/scala-swing_2.13/latest/index.html for scala 2.13 and https://javadoc.io/doc/org.scala-lang.modules/scala-swing_3/latest/index.html for scala 3.

Current Work

Current changes are being made on the work branch. Last published version is found on the main branch.

Publishing New Versions

We assume that you are working on a fork of remote upstream with remote origin.

  • create a new local branch that will never be pushed remotely, e.g. git checkout -b release-3.0.0#3.0.0-RC2 (do not name the branch the same as a tag)
  • edit .travis.yml to reduce the matrix to only the Scala and JDK versions needed to publish the version (publishing JDK is 8)
  • git commit
  • 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'
  • push only the tag, e.g. git push upstream v3.0.0#3.0.0-RC2.
  • check CI status at https://travis-ci.com/github/scala/scala-swing. You should see a message Running ci-release. followed by e.g published scala-swing_3.0.0-RC2 to ... going into local sonatype-staging, followed by the Sonatype plugin uploading the artifacts.
  • Upon success, nudge Seth to release the bundle from Sonatype.

scala-swing's People

Contributors

adriaanm avatar andy1138 avatar benhutchison avatar catull avatar dragos avatar gkossakowski avatar gourlaysama avatar heathermiller avatar ingoem avatar jsuereth avatar kijuky avatar lrytz avatar milessabin avatar nthportal avatar odersky avatar paulp avatar phaller avatar philippus avatar reggert avatar retronym avatar rtyley avatar rusty-snake avatar sciss avatar sethtisue avatar soc avatar szeiger avatar tiarkrompf avatar vincentdehaan avatar xeno-by avatar xuwei-k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scala-swing's Issues

No Events Published from ListModel for ListView

User code will not receive ListDataEvent because the model in ListView is replaced by another model in the later part of ListView constructor. As a result, the user code has to add the listener explicitly to the "other" model manually to get model's events. The same goes for new model added to ListView.

Please refer to the code attached.

Incorrect CellEditor for Table when column is null

In scala.swing.Table the default editor behaviour differs from the expected. The TableModel interface contains the method getColumnClass which I expected to be used to determine the type of a column in order to select the right cell editor. Instead the code looks at the value in the cell and if it is null the default editor for Object is used.

  // TODO: a public API for setting editors
  protected def editor(row: Int, column: Int) = {
    val v = apply(row, column).asInstanceOf[AnyRef]
    if (v != null)
      Table.this.peer.getDefaultEditor(v.getClass)
    else
      Table.this.peer.getDefaultEditor(classOf[Object])

Use case where this breaks: I have a date column in a table which might be null. When null I cannot enter a valid date since the wrong editor is used.

This is how I expected the code to look:

  def editor(row: Int, column: Int) = 
    peer.getDefaultEditor(peer.getModel.getColumnClass(column))

Milestone build for both scala-2.10 and 2.11 (scala-swing-M2)

Hi @adriaanm (/cc @fommil )
I've been asked for a scala-2.10 version so I've managed to change the build (it was only the addition to .travis.yml of scala-2.10) but that means that I need to inc the milestone number to M2 (M1 was good practice :-) )

The travis build look ok but I cannot see the sonatype destinations (asks for login ) but I think that is something on your side, can you check and do your thing.

Thanks

Travis 2.10 job: https://travis-ci.org/scala/scala-swing/jobs/50086905
Travis 2.11 job: https://travis-ci.org/scala/scala-swing/jobs/50086903

TabbedPane.Page should not set empty tooltip

The default tool tip is "", and the constructor does tip = tip0, resulting, depending on the look and feel, in an empty but nevertheless visible/popping up tool tip.

Probably the call to setToolTipTextAt should map "" to null.

add spreadsheet example from Odersky Venners & Spoon book to test sources

@Sciss writes at #76 (comment) :

Regarding the book examples, the best would probably be to simply drop them into test sources, so we would automatically detect if there is a deviation introduced. I have printed copy of edition 2 somewhere buried, and the PDF of edition 1; could you perhaps - if you have PDF of the latest edition - just send me the code examples, then I can add them. In the version I'm seeing, that's listings 32.1 through 32.4, 33.1 through 33.9 ; or if they've never changed, I can copy them from my sources.

@bvenners do you have the code for this...?

swing.Publisher does not always notify all listeners

So here is something that had me scratch my head for quite some time. Sometimes, Reactors would not get notified by a publisher. This didn't happen very often, but often enough to break some functionality.

It turned out that it was caused by the mutable nature of the swing.Publisher#listeners. More precisely, it sometimes happens when a listener, in reaction to an event, decides to unsubscribe from the publisher, i.e., calls deafTo(). This immediately causes the listeners to change state, and therefore may lead to the for comprehension to terminate early, without notifying subsequent listeners.

I think that "if a specific event happens on a publisher, I'm not interested in that publisher anymore" is a valid and not terribly exotic use case for a Reactor, so I consider the current behavior a bug.

I'm attaching a scalatest class which triggers the bug (and also contains one possible solution).

scala.swing.ComboBox should support mutable item lists

To enable dynamical Swing comboboxes, scala.swing.ComboBox should also be able to use the MutableComboBoxModel. Something like the addition of a mutable model in addition to the existing constant model:

class MutableModel[A](items: Buffer[A]) extends ConstantModel(items) with MutableComboBoxModel {
   def removeElementAt( n: Int ) = items.remove( n )
   def removeElement( item: Any ) = items.remove( items.indexOf(item) )
   def insertElementAt( item: Any, n: Int ) = items.insert( n, item.asInstanceOf[A] )
   def addElement( item: Any ) = items.append( item.asInstanceOf[A] )
}

The choice of the model could depend on some parameters in the constructor (e.g. matching Seq or Buffer).

scala.swing.Window.contents_=() should not call pack()

in trunk as of april 22 2010:

scala.swing.Window:

37  override def contents_=(c: Component) {
38	    super.contents_=(c)
39	    peer.pack() // pack also validates, which is generally required after an add
40	  }

As can be seen, 'pack()' is called when changing the content of a Window. This is generally NOT what you want. Pack() has the function to resize a window to fit its contents. It's an optional feature. It is normally NOT desired when the programmer sets the size explicitly (using size = ...). It is in general NOT desired when the window has a size set before.

This can cause the window of the app to be suddenly resized when it sets e.g. a new mainpanel in it. E.g. a bank-app; Window resizes when the initial overview screen is installed; resizes again (!) when this is replaced by some detail screen.

To make things worse, imagine the end-user to resize the window to it's liking, which will be undone when the content of the window changes! (caused by this 'pack()')! That would def. be regarded as a bug.

It MIGHT be a nice initial, one-time, fallback auto-behaviour in the case when the window doesn't have a size set yet, but is requested to be displayed. (The pack() call should be moved to that function then and some condition state-checking should be added to the class).[[BR]]
BUT EVEN THEN, I am not sure that there are no valid cases for wanting to display a window with a 'zero' size (if that's the default for a window).

Add support for smallIcon property in Action and use it in MenuItem constructors

javax.swing.Action (http://docs.oracle.com/javase/7/docs/api/javax/swing/Action.html ) uses two keys to set the icon property of the components that are constructed with Action instances. The two are LARGE_ICON_KEY and SMALL_ICON. The LARGE_ICON_KEY is used to set the icon property of most Swing components that are AbstractButtons except for MenuItems. The SMALL_ICON property applies when the Action is used to construct MenuItems.

scala.swing.Action should have defs for smallIcon. The MenuItem constructor that takes an Action argument should assign MenuItem icon with the value from Action.smallIcon.

The existing icon defs in scala.swing.Action can remain unchanged.

Request for a scala.swing.CardPanel (uses javax.swing.CardLayout)

Here is a simple implementation:

import swing.{Component, LayoutContainer, Panel}
import java.awt.CardLayout

class CardPanel extends Panel with LayoutContainer {
  type Constraints = String
  def layoutManager = peer.getLayout.asInstanceOf[CardLayout]
  override lazy val peer = new javax.swing.JPanel(new CardLayout) with SuperMixin

  private var cards : Map[String, Component] = Map.empty

  protected def areValid(c: Constraints) = (true, "")
  protected def add(comp: Component, l: Constraints) = {
    // we need to remove previous components with the same constraints as the new one,
    // otherwise the layout manager loses track of the old one
    cards.get(l).foreach { old => cards -= l; peer.remove(old.peer) }
    cards += (l -> comp)
    peer.add(comp.peer, l)
  }

  def show(l : Constraints) = layoutManager.show(peer, l)

  protected def constraintsFor(comp: Component) = cards.iterator.find { case (_, c) => c eq comp}.map(_._1).orNull
}

Creating a release from a tag

Hi @adriaanm

Following on from #33

I'm trying to get a tagged release (tag: v2.0.0-M2) of the java7 branch onto sonatype/maven.com however, as you may guess, its not arriving. I'm copied all your changes to 'master' to the 'java7' branch, hopefully successfully :-)

I'm

Do you know what I'm doing wrong or who to talk to
Thanks
Andy

Component/Publisher initialization may be broken -- or is somewhat obscure

I'm not quite sure whether this is a bug or intended behavior: A Publisher automatically listens to itself, "for convenience". For a Component, this call to listenTo() calls Publisher's subscribe, not LazyPublisher's - because it happens within initialization, if I'm correct. Additionally, LazyPublisher.subscribe checks for listeners.size == 1 rather than 0. Is this the way it was meant to be? If so, it is at least very obscure, and it would be nice of you to add some comment, because it's hard to tell from the code what's going on and how it should be used.

My current solution is to call listenTo(this) again in my Component subclass. This works for me, but is this how you intended it to be used? Is the calling of listenTo(this) in Publisher really a good thing? Maybe it makes things more complicated than it's worth... What do you think?

Christoph

1.0.x branch (inadvertently?) dropped support for Java 6 & 7 and Scala 2.10

it came up over at scala/sbt-scala-module#32 that @Sciss thought scala-swing was built on Java 6. I thought it was too, and the repo readme here claims it is.

but it isn't. it was, but at some point, it changed, perhaps inadvertently. I looks to me like changes were made on the 1.0.x branch that should probably only been made on 2.0.x. this included building on JDK 8 only and also dropping support for Scala 2.10, which the readme also claims 1.0.x supports.

as for the related sbt version issue:

  • I think it's fine for 1.0.x to stay on 0.13.x indefinitely
  • for 2.0.x to move to sbt 1, it would have to drop JDK 6 and 7 support. @Sciss indicated a desire to keep supporting JDK 6 and 7, but I'm not sure if he cares about that on 2.0.x too, or whether keeping the support on the 1.0.x branch is enough. (@Sciss, if you decide 2.0.x should stay on sbt 0.13, that's fine w/ me.)

scala.swing.Menu contents field permanently empty

The following code prints 0, the length of the menu's contents field, but it should be 1. It is also impossible to access the elements in contents.

It is interesting to note, however, that if the menu was to be shown, it would indeed have the item "foobar" in it.

import scala.swing._
val menu = new Menu("File") {
  contents += new MenuItem("foobar")
}
println(menu.contents.length)

publish scaladoc

Since scala-swing has been offloaded into this module, I can not find the scaladoc to it anywhere. The scaladoc for previous versions, i.e. before scala 2.11, have been together with the scala-library at docs.scala-lang.org. Is there some place where the scaladoc is published? If not, pretty please publish it and link to it from this projects README.md.

Missing GroupPanel

I miss the GroupPanel (Scala 2.8 RC1). So I have implemented a first simple version.
It does not yet offer all features of GroupPanel, but you can write
some gui very easy and straightforward.

Attached you find the GroupPanel.scala and 2 demo apps.

scala.swing.Table column sorts are broken

Invoking javax.swing.JTable (or hiding this invocation in scala.swing.Table) causes the table head to change to enable sorting. Selecting a row before clicking on the table head makes the selection highlighting to move. But the data in the rows does not move. The code below works with the java7 branch (October 19, 2014). It is possible to get rid of the remaining peer calls with simple modifications to the source.

scala.swing.Scrollable does not implement javax.swing.Scrollable in peer

A component that extends scala.swing.Scrollable (but not Scrollable.Wrapper) should cause the component's peer to implement javax.swing.Scrollable and forward the latter's methods to the former. That way, custom components can be made scrollable.

In 2.8.0, this is not the case. Rather, extending scala.swing.Scrollable and implementing its methods for a custom scrollable component has no effect, since the resulting peer doesn't implement javax.swing.Scrollable.

subscribe event handler disconnects randomly

For some background see,
https://class.coursera.org/reactive-002/forum/thread?thread_id=719
https://class.coursera.org/reactive-002/forum/thread?thread_id=703

Below is the standalone code that demonstrates the hang for me. Note that after it hangs the GUI still continues to function - So when I say hangs - I mean the console output stops - so the event handler seems to be disconnected.

The hanging behaviour is easy to demonstrate: see the second comment.

Happens on Windows 7 64 bit Java 1.7.0_45 sbt 0.13.8 scalaVersion := "2.11.5" I'm running under sbt / clean / run.
And also under Xubuntu 14.1064 bit under sbt/clean/run and maven as described below:

Here is a tiny self contained example:

pom.xml in root directory:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>SuggestionScalaSwingHang</groupId>
    <artifactId>SuggestionScalaSwingHang</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <repositories>
        <repository>
            <id>scala-tools.org</id>
            <name>Scala-Tools Maven2 Repository</name>
            <url>http://scala-tools.org/repo-releases</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>scala-tools.org</id>
            <name>Scala-Tools Maven2 Repository</name>
            <url>http://scala-tools.org/repo-releases</url>
        </pluginRepository>
    </pluginRepositories>
    <dependencies>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>2.11.0</version>
        </dependency>
        <dependency>
            <groupId>org.scala-lang.modules</groupId>
            <artifactId>scala-swing_2.11</artifactId>
            <version>1.0.2</version>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.scala-tools</groupId>
                    <artifactId>maven-scala-plugin</artifactId>
                    <version>2.15.2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.3</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.scala-tools</groupId>
                <artifactId>maven-scala-plugin</artifactId>
                <executions>
                    <execution>
                        <id>scala-compile-first</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>add-source</goal>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <finalName>uber</finalName>
                            <minimizeJar>false</minimizeJar>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>suggestions.gui.SwingHangExample</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

and here's the one source file under src/main/scala/suggestions/gui/WikipediaSuggest.scala:

package suggestions
package gui

import scala.swing.BoxPanel
import scala.swing.Dimension
import scala.swing.MainFrame
import scala.swing.Orientation.Vertical
import scala.swing.Reactions
import scala.swing.Reactions.Reaction
import scala.swing.SimpleSwingApplication
import scala.swing.Swing.EmptyBorder
import scala.swing.event.Event
import javax.swing.SwingUtilities

object SwingHangExample extends SimpleSwingApplication
{
  def init(field: scala.swing.TextField)   = {
    val r: Reactions.Reaction = {
      case(e: Event) => {
        println("size:" + field.text.length + " " + SwingUtilities.isEventDispatchThread());
      }
      case _ => {
        println("??? size:" + field.text.length + " " + SwingUtilities.isEventDispatchThread());
      }
    }
    field.subscribe(r)
  }

  def top = new MainFrame {

    title = "Hold down a key and wait for a few minutes - console output stops, but GUI remains operational"
    minimumSize = new Dimension(900, 100)

    val searchTermField = new scala.swing.TextField

    contents = new BoxPanel(orientation = Vertical) {
      border = EmptyBorder(top = 5, left = 5, bottom = 5, right = 5)
      contents += searchTermField
    }

    println(System.getProperty("java.version"))

    init(searchTermField)
  }
}

Build with (in root directory):

mvn -U clean package

Run with

java -jar target/uber.jar

Guidelines for contributing

Should a CONTRIBUTING.md guide be added? What is the policy now that the project is "community maintained". Is there still a CLA that needs to be signed, etc.?

And what would be the forum to discuss; should there be dev gitter room or so?

Table row-sorting is broken

See this StackOverflow problem that contains a demonstration example. The bug apparently is in the override of the cell renderer in the peer object. The following "fixes" the bug:

new Table {
  // disable broken renderer
  override lazy val peer: JTable = new JTable with SuperMixin
}

So the getCellRenderer must be doing something wrong in terms of view versus model indices.

Perhaps related: #30 (says column-sorting though)

GridBagPanel is inflexible

Suggested changes:

  • Constraints should be a member of the companion object rather than the class, as there's no reason to tie constraint construction to a particular panel instance.

  • The add method should not be protected. That may have made sense if GridBagPanel is to be used only declaratively, but arguably this layout is too complex for that. Rather, it's a prime candidate for wrapping by some application-specific declarative framework, in which case the protection is just a pain.

  • The single mutating constraints object as used in the demo code is nasty. Ideally Constraints should be a case class with keyword arguments.

Scala 2.13.0(-M5) support

We need some help getting this done. As Scala Swing heavily relies on the collections API, I assume this is not a trivial task. Opening this issue as a point of contact.

scala.swing.dialog.Result - Duplicate id: 0

is defined:

  object Result extends Enumeration {
    import JOptionPane._
    val Yes   : Result.Value = Value(YES_OPTION)
    val Ok    : Result.Value = Value(OK_OPTION)
    val No    : Result.Value = Value(NO_OPTION)
    val Cancel: Result.Value = Value(CANCEL_OPTION)
    val Closed: Result.Value = Value(CLOSED_OPTION)
  }

where

public static final int YES_OPTION = 0;
public static final int OK_OPTION = 0;
public static final int NO_OPTION = 1;
public static final int CANCEL_OPTION = 2;
public static final int CLOSED_OPTION = -1;

As you can see both YES_OPTION and OK_OPTION is bound to 0.

This causes:

Exception in thread "AWT-EventQueue-1" java.lang.AssertionError: assertion failed: Duplicate id: 0
	at scala.Enumeration$Val.<init>(Enumeration.scala:237)
	at scala.Enumeration.Value(Enumeration.scala:177)
	at scala.Enumeration.Value(Enumeration.scala:160)
	at scala.swing.Dialog$Result$.<init>(RichWindow.scala:124)
	at scala.swing.Dialog$Result$.<clinit>(RichWindow.scala)

when:

Dialog.showConfirmation(
            parent = null,
            message = "asdf",
            title = "asdf",
            optionType = Dialog.Options.Default,
            messageType = Dialog.Message.Question)

community: open issues here for any significant old issue from JIRA

today I closed the following scala-swing tickets in the Scala JIRA instance:
8495, 7827, 7742, 7738, 7597, 7309, 7307, 5701, 5616, 5492, 5381, 4998, 4905, 4904, 4903, 4823, 4078, 3933, 3823, 3557, 3335, 3319, 3259, 2362, 2154, 2069, 1824, 1613

many of these ought to become issues here in this repo on GitHub. interested community members are invited to open new issues for them here, with links in both directions

Missing the property iconImages in RichWindow

In order to make a professional swing application. I would need the possibility to add multiple, differently sized Images to the top frame.

If you can add only one icon, The icon is automatically shrieked to very low quality.

Swing TextAction

There is a swing.Action with peer javax.swing.Action,
but there is no TextAction with peer javax.swing.text.TextAction.

From the API of javax.swing.text.TextAction

 * An Action implementation useful for key bindings that are shared across
 * a number of different text components.

A TextAction has no explicit reference to a TextCompont,
but it acts on the last focused TextComponent. So you can have
a MenuItem with a TextAction which can act on each
TextComponent of the swing application.

Attached there is an implementation and an example app with
TextAction changing the fontsize.

Frank

scala.swing.Action title should really be text.

Action contains the code
def title: String = ifNull(peer.getValue(javax.swing.Action.NAME),"")
def title_=(t: String) { peer.putValue(javax.swing.Action.NAME, t) }

The javax swing JavaDoc for Action http://docs.oracle.com/javase/7/docs/api/javax/swing/Action.html
manipulates the component property "text", not "title".

Action is not in the class inheritance hierarchy of any other component, so adding text defs is safe. Removing title opens up a backwards compatibility issue.

java 7 and scala 2.9.2

We need a compile-path friendly version of scala-swing that works with java 7 and scala 2.9, but it seems that your java 7 branch only supports scala 2.10.

Are there any plans to release java 7 friendly jars anytime soon? (from all discussions I see, this doesn't sound likely)

In lieu of this, which commit hash should I use to create a s2.9/j7 fork?

Publish as `2.0.0` without `M2` suffix?

I maintain legacy lib ScalaSwingContrib and are publishing for 2.12. Was surprised to find only a milestone builds for 2.12.x.

Seems there isn't any likely prospect of much more work on Swing lib, so could we re-publish as 2.0.0? The M2 suffix suggests expected changes coming...

Testing Ive done with M2 on 2.12:

Unit tests for ScalaSwingContrib plus manual testing of its 3 demos all look good

 [1] scalaswingcontrib.test.ColorChooserDemo
 [2] scalaswingcontrib.test.TreeDemo
 [3] scalaswingcontrib.test.group.GroupLayoutDemo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.