scala-swing

Discard all messages except the last one in a Scala actor

ε祈祈猫儿з 提交于 2020-01-03 03:21:08
问题 I have a SwingWorker actor which computes a plot for display from a parameters object it gets send; then draws the plot on the EDT thread. Some GUI elements can tweak parameters for this plot. When they change I generate a new parameter object and send it to the worker. This works so far. Now when moving a slider many events are created and queue up in the worker's mailbox. But I only need to compute the plot for the very last set of parameters. Is there a way to drop all messages from the

Problems with Scala Swing library

两盒软妹~` 提交于 2020-01-02 12:54:30
问题 Hello I am having problems when using the Scala Swing library in version 2.8 Beta1-prerelease. I have a situation where I want to show a table in GUI, and update it as results are returned from a SQL request. Which way could this be done in Scala, at the moment i am using the DefaultTableModel from Java library. Another thing is that I want the table to be sortable afterwards, I cant see if Scala swing library supports this either? 回答1: No - the scala swing library does not support sorting of

Problems with Scala Swing library

空扰寡人 提交于 2020-01-02 12:53:45
问题 Hello I am having problems when using the Scala Swing library in version 2.8 Beta1-prerelease. I have a situation where I want to show a table in GUI, and update it as results are returned from a SQL request. Which way could this be done in Scala, at the moment i am using the DefaultTableModel from Java library. Another thing is that I want the table to be sortable afterwards, I cant see if Scala swing library supports this either? 回答1: No - the scala swing library does not support sorting of

Scala Swing event framework - where do I add my reactors?

為{幸葍}努か 提交于 2019-12-18 17:04:34
问题 I'm trying to catch a mouse-click even on a Table (which should cause a popup to be shown). The table is inside a ScrollPane which is (in turn) inside a Panel . I have added reactions to all the classes, but I can never seem to actually get a click event to be caught! class MyPanel extends GridBagPanel { val gbc = new GridBagContraints( ... ) add(new ScrollPane { reactions += { case MouseClicked(src, point, mod, clicks, pops) => println("Scroll pops: " + pops) } viewportView = new Table {

Scala Swing Newbie

点点圈 提交于 2019-12-10 21:23:17
问题 Im trying to create an login window for an app im doing. I have searched all day for an example but I cant seem to find anything that helps. My basic structure is as follows: // App.scala object App extends SimpleSwingApplication { val ui = new BorderPanel { //content } def top = new MainFrame { title = "title" contents = ui } } So whats the strategy to create a login box without the mainframe showing and closing it after login and displaying the mainframe. thanks 回答1: Here is working example

Why is this reference ambiguous?

纵然是瞬间 提交于 2019-12-06 23:17:13
问题 import swing._ object PeerTest extends SimpleSwingApplication { def top = new MainFrame { val p = peer.getMousePosition } } gives error: ambiguous reference to overloaded definition, both method getMousePosition in class Container of type (x$1: Boolean)java.awt.Point and method getMousePosition in class Component of type ()java.awt.Point match expected type ? val p = peer.getMousePosition but adding the type val p: Point = peer.getMousePosition makes it ok. Why? edit: causes problem: class A

Discard all messages except the last one in a Scala actor

夙愿已清 提交于 2019-12-06 15:26:38
I have a SwingWorker actor which computes a plot for display from a parameters object it gets send; then draws the plot on the EDT thread. Some GUI elements can tweak parameters for this plot. When they change I generate a new parameter object and send it to the worker. This works so far. Now when moving a slider many events are created and queue up in the worker's mailbox. But I only need to compute the plot for the very last set of parameters. Is there a way to drop all messages from the inbox; keep the last one and process only that? Currently the code looks like this val worker = new

Problems with Scala Swing library

白昼怎懂夜的黑 提交于 2019-12-06 14:09:05
Hello I am having problems when using the Scala Swing library in version 2.8 Beta1-prerelease. I have a situation where I want to show a table in GUI, and update it as results are returned from a SQL request. Which way could this be done in Scala, at the moment i am using the DefaultTableModel from Java library. Another thing is that I want the table to be sortable afterwards, I cant see if Scala swing library supports this either? No - the scala swing library does not support sorting of Table - your best best is to revert to using JTable (i.e. the java swing class). A couple of things to note

Why is this reference ambiguous?

耗尽温柔 提交于 2019-12-05 03:52:43
import swing._ object PeerTest extends SimpleSwingApplication { def top = new MainFrame { val p = peer.getMousePosition } } gives error: ambiguous reference to overloaded definition, both method getMousePosition in class Container of type (x$1: Boolean)java.awt.Point and method getMousePosition in class Component of type ()java.awt.Point match expected type ? val p = peer.getMousePosition but adding the type val p: Point = peer.getMousePosition makes it ok. Why? edit: causes problem: class A { def value() = 123 } class B extends A { def value(b: Boolean) = 42 } object Main extends App {

Scala Swing event framework - where do I add my reactors?

孤人 提交于 2019-11-30 14:19:22
I'm trying to catch a mouse-click even on a Table (which should cause a popup to be shown). The table is inside a ScrollPane which is (in turn) inside a Panel . I have added reactions to all the classes, but I can never seem to actually get a click event to be caught! class MyPanel extends GridBagPanel { val gbc = new GridBagContraints( ... ) add(new ScrollPane { reactions += { case MouseClicked(src, point, mod, clicks, pops) => println("Scroll pops: " + pops) } viewportView = new Table { reactions += { case MouseClicked(src, point, mod, clicks, pops) => println("Table pops: " + pops) } ... }