当前位置: 首页>>代码示例>>Scala>>正文


Scala ButtonClicked类代码示例

本文整理汇总了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
    }
  }
} 
开发者ID:mhotchen,项目名称:programming-in-scala,代码行数:26,代码来源:First.scala

示例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)
		}
	}
} 
开发者ID:Takeuchi-Lab-LM,项目名称:scala_asa3,代码行数:51,代码来源:GuiAsa.scala

示例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!")
  }
} 
开发者ID:JaromirCharles,项目名称:SE-Phase-10,代码行数:30,代码来源:Phasen.scala

示例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
  }
} 
开发者ID:wracker1,项目名称:ticket-booker,代码行数:22,代码来源:ReactorOps.scala

示例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
    }
  }
} 
开发者ID:bpupadhyaya,项目名称:scala-programs-collection,代码行数:33,代码来源:SwingAppButton2.scala

示例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 ms popular" }
  contents += butPerroPopular

  val butOpcion1 = new Button { text = "Opcin 1" }
  contents += butOpcion1

  val butOpcion2 = new Button { text = "Opcin 2" }
  contents += butOpcion2

  listenTo(butPerroPopular, butOpcion1, butOpcion2)
  reactions += {
    case ButtonClicked(`butPerroPopular`) => {
      val perroMasPopular = principal.perroPopular
      Dialog.showMessage(contents.head, perroMasPopular.nombre, title = "Perro ms popular")
    }
    case ButtonClicked(`butOpcion1`) => {
      Dialog.showMessage(contents.head, principal.opcion1, title = "Opcin 1")
    }
    case ButtonClicked(`butOpcion2`) => {
      Dialog.showMessage(contents.head, principal.opcion2, title = "Opcin 2")
    }
  }
} 
开发者ID:ncardozo,项目名称:scalakids,代码行数:35,代码来源:PanelOpciones.scala

示例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), "Navegacin")
  
  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
    }
  }
} 
开发者ID:ncardozo,项目名称:scalakids,代码行数:38,代码来源:PanelNavegacion.scala

示例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
} 
开发者ID:ReactionMap,项目名称:RMapViewerS,代码行数:49,代码来源:ScratchingBrowser.scala


注:本文中的scala.swing.event.ButtonClicked类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。