本文整理汇总了Scala中scala.swing.event.ButtonClicked类的典型用法代码示例。如果您正苦于以下问题:Scala ButtonClicked类的具体用法?Scala ButtonClicked怎么用?Scala ButtonClicked使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ButtonClicked类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: First
//设置package包名称以及导入依赖的类
package swing
import scala.swing._
import scala.swing.event.ButtonClicked
object First extends SimpleSwingApplication {
def top = new MainFrame {
title = "My first swing app"
val button = new Button{ text = "Click me" }
val label = new Label{ text = "The button hasn't been clicked yet" }
contents = new BoxPanel(Orientation.Vertical) {
contents += button
contents += label
border = Swing.EmptyBorder(30, 30, 10, 30)
}
var clicks = 0
listenTo(button)
reactions += {
case ButtonClicked(b) if b == button =>
clicks += 1
label.text = "Number of button clicks: " + clicks
}
}
}
示例2: GuiAsa
//设置package包名称以及导入依赖的类
package cl.asa
import cl.asa.yaml._
import cl.asa.init._
import cl.asa.parse._
import cl.asa.result._
import cl.asa.output._
import scala.swing._
import scala.swing.event.ButtonClicked
object GuiAsa extends SimpleSwingApplication {
//print("???\r")
var analyzer: String = "cabocha -n1 -f1"
private val file = new YamlFile()
private val dicts = new LoadYaml(file)
private val parser = new Parse(dicts,analyzer)
private val output = new Output("test")
private val goutput = new GuiOutput()
private val otype = "all"
def top = new MainFrame {
title = "ASA"
minimumSize = new Dimension(300, 200)
contents = mainPanel
}
val mainPanel = new BoxPanel(Orientation.Vertical) {
val b1 = new Button("??")
val t1 = new TextField("?????")
contents += t1
contents += b1
b1.reactions += {
case ButtonClicked(b1) => {
val result = parser.parse(t1.text)
goutput.outputAll(result)
//selectOutput(otype, result)
}
}
}
private def selectOutput(otype: String, result: Result) {
otype match {
case "all" => output.outputAll(result)
case "semantic" => output.outputSemantic(result)
case "yaml" => output.outputYaml(result)
}
}
}
示例3: Phasen
//设置package包名称以及导入依赖的类
package de.htwg.se.phase10.aview.gui
import swing._
import javax.swing.ImageIcon
import de.htwg.se.phase10.controller.IController
import scala.swing.event.ButtonClicked
class Phasen(gui:createGameField,name:String,controller:IController) extends Frame {
val color = new Color(0x00592D)
def phasenCard = new FlowPanel() {
contents += card
background = color
}
val card = new Button {
this.preferredSize_=(new Dimension(100,120))
this.icon_=(new ImageIcon(new ImageIcon("./img/phasen.jpg").getImage().getScaledInstance(100,120, java.awt.Image.SCALE_SMOOTH)))
this.borderPainted_=(true)
}
listenTo(card)
reactions += {
case ButtonClicked(`card`) if (!gui.willMove && !controller.getMove() && !gui.playerMenu) => gui.willMove = true;gui.move.updateMove; gui.move.top.visible_=(true)
case ButtonClicked(`card`) if(gui.willMove || gui.playerMenu) =>
case ButtonClicked(`card`) => gui.infoFeld.turnPhase.text_=("You did this phase already!")
}
}
示例4: createButton
//设置package包名称以及导入依赖的类
package jesse.lee.ops
import scala.swing.event.ButtonClicked
import scala.swing.{Button, Reactor}
trait ReactorOps extends Reactor {
def createButton(title: String)(action: => Unit) = {
val button = new Button {
text = title
}
reactions += {
case ButtonClicked(`button`) => action
}
listenTo(button)
button
}
}
示例5: SwingAppButton2
//设置package包名称以及导入依赖的类
package com.equalinformation.scala.programs.gui
import scala.swing._
import scala.swing.event.ButtonClicked
object SwingAppButton2 extends SimpleSwingApplication {
override def top: Frame = new MainFrame {
title = "Swing App with Button - 2"
val button = new Button {
text = "Click here"
}
val label = new Label {
text = "No button clicked yet"
}
contents = new BoxPanel(Orientation.Vertical) {
contents += button
contents += label
border = Swing.EmptyBorder(30,40,15,40)
}
listenTo(button)
var nClicks = 0
reactions += {
case ButtonClicked(b) =>
nClicks += 1
label.text = "Number of button clicks: "+nClicks
}
}
}
示例6: PanelOpciones
//设置package包名称以及导入依赖的类
package uniandes.cupi2.dogBook.interfaz
import scala.swing.GridPanel
import scala.swing._
import java.awt.Color
import scala.swing.event.ButtonClicked
class PanelOpciones(principal: InterfazDogBook) extends GridPanel(1, 3) {
border = Swing.TitledBorder(Swing.LineBorder(Color.LIGHT_GRAY), "Opciones")
val butPerroPopular = new Button { text = "Perro ms popular" }
contents += butPerroPopular
val butOpcion1 = new Button { text = "Opcin 1" }
contents += butOpcion1
val butOpcion2 = new Button { text = "Opcin 2" }
contents += butOpcion2
listenTo(butPerroPopular, butOpcion1, butOpcion2)
reactions += {
case ButtonClicked(`butPerroPopular`) => {
val perroMasPopular = principal.perroPopular
Dialog.showMessage(contents.head, perroMasPopular.nombre, title = "Perro ms popular")
}
case ButtonClicked(`butOpcion1`) => {
Dialog.showMessage(contents.head, principal.opcion1, title = "Opcin 1")
}
case ButtonClicked(`butOpcion2`) => {
Dialog.showMessage(contents.head, principal.opcion2, title = "Opcin 2")
}
}
}
示例7: PanelNavegacion
//设置package包名称以及导入依赖的类
package uniandes.cupi2.dogBook.interfaz
import scala.swing._
import java.awt.Color
import scala.swing.event.ButtonClicked
class PanelNavegacion(principal: InterfazDogBook) extends GridPanel(1,5) {
border = Swing.TitledBorder(Swing.LineBorder(Color.BLACK), "Navegacin")
val butPrimero = new Button { text = "Ver primer perro" }
val butAnterior = new Button { text = "<<" }
val butBuscar = new Button { text = "Buscar" }
val butSiguiente = new Button { text = ">>" }
val butUltimo = new Button { text = "Ver timo perro" }
listenTo(butPrimero, butAnterior, butBuscar, butSiguiente, butUltimo)
contents += (butPrimero, butAnterior, butBuscar, butSiguiente, butUltimo)
reactions += {
case ButtonClicked(`butPrimero`) => {
principal.primero
}
case ButtonClicked(`butAnterior`) => {
principal.anterior
}
case ButtonClicked(`butBuscar`) => {
principal.buscar
}
case ButtonClicked(`butSiguiente`) => {
principal.siguiente
}
case ButtonClicked(`butUltimo`) => {
principal.ultimo
}
}
}
示例8: ScratchingBrowser
//设置package包名称以及导入依赖的类
package application
import graph.Vertex
import widgets.{MoleculeList, MoleculeSketch, PeriodicTable}
import scala.swing._
import scala.swing.event.ButtonClicked
object ScratchingBrowser extends Frame {
val periodicTable = new PeriodicTable()
val moleculeSketch = new MoleculeSketch()
val moleculeList = new MoleculeList()
override val title = "RMapViewer"
contents = new BoxPanel(Orientation.Horizontal) {
contents += new BoxPanel(Orientation.Vertical) {
contents += new Button("Clear all") {
reactions += {
case _: ButtonClicked =>
moleculeSketch.clear()
}
}
contents += moleculeSketch
contents += periodicTable
}
contents += new BoxPanel(Orientation.Vertical) {
contents += new Button("Search") {
reactions += {
case _: ButtonClicked =>
updateMoleculeList()
}
}
contents += moleculeList
}
}
def updateMoleculeList() = {
val geometrySignature = moleculeSketch.geometrySignature
val structureSignature = moleculeSketch.structureSignature
moleculeList.update(RMapViewer.rmap.vertices.toList
.filter((vertex:Vertex)=>vertex.structureSignature == structureSignature)
.map((vertex: Vertex) => (vertex, geometrySignature.dist(vertex.geometrySignature)))
.sortWith { case (less: (Vertex, Double), more: (Vertex, Double)) => less._2 <= more._2 }
.map(_._1))
}
def atom = periodicTable.value
}