• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala ActionListener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中java.awt.event.ActionListener的典型用法代码示例。如果您正苦于以下问题:Scala ActionListener类的具体用法?Scala ActionListener怎么用?Scala ActionListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ActionListener类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: TrayIcon

//设置package包名称以及导入依赖的类
package se.gigurra.dcs.remote

import java.awt
import java.awt._
import java.awt.event.{ActionEvent, ActionListener}
import javax.swing.ImageIcon

import se.gigurra.serviceutils.twitter.logging.Logging

case class TrayIcon(exitCallback: () => Unit) {

  val base = createImage("tray_icons/base.png", "base")
  val popup = new PopupMenu()
  val trayIcon = new awt.TrayIcon(base)
  val tray = SystemTray.getSystemTray
  val exitItem = new MenuItem("Exit")
  exitItem.addActionListener(new ActionListener { override def actionPerformed(e: ActionEvent): Unit = exitCallback() })

  trayIcon.setToolTip("DCS-Remote REST Proxy")
  popup.add(exitItem)
  trayIcon.setPopupMenu(popup)
  tray.add(trayIcon)

  def createImage(path: String, description: String): Image = {
    val imageURL = getClass.getClassLoader.getResource(path)
    if (imageURL == null) {
      throw new RuntimeException("Resource not found: " + path)
    } else {
      new ImageIcon(imageURL, description).getImage
    }
  }

}

object TrayIcon extends Logging{

  def setup(): Option[TrayIcon] = {
    SystemTray.isSupported match {
      case true =>
        logger.info("Tray icon supported! Setting up tray icon..")
        Some(TrayIcon(() => System.exit(0)))
      case false =>
        logger.info("Tray icon not supported!")
        None
    }
  }
} 
开发者ID:GiGurra,项目名称:dcs-remote2,代码行数:48,代码来源:TrayIcon.scala


示例2: ClustersDriver

//设置package包名称以及导入依赖的类
package sryza

import java.awt.Cursor
import java.awt.event.{ActionEvent, ActionListener}
import javax.swing._

object ClustersDriver {
  def main(args: Array[String]): Unit = {
    val splashIcon = new ImageIcon(getClass.getResource("/splash.png"))
    JOptionPane.showMessageDialog(null, "", "Clusters", JOptionPane.INFORMATION_MESSAGE, splashIcon)

    val cluster = new Cluster()
    val rootPanel = new RootPanel(cluster)

    val menuBar = new JMenuBar()
    val menu = new JMenu("Help")
    menuBar.add(menu)
    val menuItem = new JMenuItem("About")
    menuItem.addActionListener(new ActionListener {
      override def actionPerformed(e: ActionEvent): Unit = {
        JOptionPane.showMessageDialog(null,
          "Clusters is an artificial life computer program.  Gameplay focuses on raising alien\n" +
          "creatures known as Nodes.  Nodes mate, pass on their genes, get sick, execute\n" +
          "queries.")
      }
    })
    menu.add(menuItem)

    val timer = new Timer(50, new ActionListener() {
      override def actionPerformed(event: ActionEvent) = {
        cluster.gameStep()
        rootPanel.nodesPanel.repaint()
        rootPanel.statsPanel.updateStats(cluster)
        rootPanel.nodeStatsPanel.updateSelectedNode(rootPanel.nodesPanel.selectedNode)
        rootPanel.queryPanel.updateQuery()
      }
    })
    timer.start()

    val frame = new JFrame()
    frame.setJMenuBar(menuBar)
    frame.setTitle("Clusters")
    frame.setCursor(Cursor.HAND_CURSOR)
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
    frame.setContentPane(rootPanel)
    frame.pack()
    frame.setVisible(true)
  }
} 
开发者ID:sryza,项目名称:clusters,代码行数:50,代码来源:ClustersDriver.scala


示例3: TrayAdapter

//设置package包名称以及导入依赖的类
package ch.thomsch.pause

import java.awt._
import java.awt.event.{ActionEvent, ActionListener}

import scalafx.stage.Stage


object TrayAdapter {
  val image : Image  = Toolkit.getDefaultToolkit.getImage(getClass.getResource("/icon-tray.png"))

  var trayMenu = new PopupMenu
  val trayIcon : TrayIcon  = new TrayIcon(image, "Pause", trayMenu)
  var stage : Stage = null
  val tray : SystemTray = SystemTray.getSystemTray

  def initialize(): Unit = {
    val exit: MenuItem = new MenuItem("Exit")
    val controls: MenuItem = new MenuItem("Settings...")
    controls.setFont(Font.decode(null).deriveFont(Font.BOLD))

    trayMenu.add(controls)
    trayMenu.addSeparator()
    trayMenu.add(exit)

    val listener : ActionListener= new ActionListener() {
      def actionPerformed(arg0 : ActionEvent ) {
        Actions.closeApplication()
      }
    }

    val settingsListener : ActionListener = new ActionListener {
      override def actionPerformed(e: ActionEvent) : Unit = {
        if(Pause.stage.isShowing) Pause.hide else Pause.show
      }
    }

    trayIcon.addActionListener(settingsListener)
    controls.addActionListener(settingsListener)
    exit.addActionListener(listener)

    tray.add(trayIcon)
  }

  def removeIcon(): Unit = {
    tray.remove(trayIcon)
  }

  def displayNotification(message : String): Unit = {
    trayIcon.displayMessage("", message, TrayIcon.MessageType.INFO)
  }

} 
开发者ID:Thomsch,项目名称:pause,代码行数:54,代码来源:TrayAdapter.scala


示例4: Editor

//设置package包名称以及导入依赖的类
package mur

import java.awt.event.{ActionEvent, ActionListener}
import akka.actor.ActorSystem
import com.typesafe.config.ConfigFactory
import scala.swing._
import scala.swing.event._

object Editor extends SimpleSwingApplication {
  val config = ConfigFactory.load
  val input = new TextArea(Main.text)
  val output = new TextArea("[0] No errors\n")
  val actorSystem = ActorSystem("mur-editor")
  val workers = actorSystem.actorOf(props = Worker.settings, name = "worker")

  def top = new MainFrame {
    title = "MuR Editor"
    preferredSize = new Dimension(
      config.getInt("gui.window-width"),
      config.getInt("gui.window-height")
    )
    contents = new BoxPanel(Orientation.Vertical) {
      contents += new ScrollPane(input)
      contents += new ScrollPane(output)
    }
    listenTo(input.keys)

    val timerListener = new ActionListener {
      override def actionPerformed(actionEvent: ActionEvent) = {
        workers ! NewInput(input.peer.getText)
      }
    }
    val timer = new javax.swing.Timer(config.getInt("gui.processing-delay"), timerListener)
    timer.setRepeats(false)
    reactions += {
      case _: KeyTyped => timer.restart()
    }
  }

  override def shutdown(): Unit = {
    actorSystem.stop(workers)
    actorSystem.terminate()
  }
} 
开发者ID:MaxGekk,项目名称:mur,代码行数:45,代码来源:Editor.scala


示例5: SAM

//设置package包名称以及导入依赖的类
import java.awt.event.{ActionEvent, ActionListener}
import javax.swing.{JButton, _}

object SAM {
  def main(args: Array[String]) {
    var data = 0
    val jFrame = new JFrame("SAM Testing")
    val jButton = new JButton("counter")
    jButton.addActionListener(new ActionListener {
      override def actionPerformed(e: ActionEvent): Unit ={
        data += 1
        println(data)
      }
    })

    implicit def convertedAction(action: (ActionEvent) => Unit) =
      new ActionListener {
        override def actionPerformed(e: ActionEvent){ action(e)}
      }

    //SAM simple abstract method??,?????????,??????????????
    jButton.addActionListener((event:ActionEvent) => {data += 1; println(data)})

    jFrame.setContentPane(jButton)
    jFrame.pack()
    jFrame.setVisible(true)

  }
} 
开发者ID:WeiLi1201,项目名称:ProgrammingNote,代码行数:30,代码来源:SAM.scala


示例6: flashFunction

//设置package包名称以及导入依赖的类
package acumen.ui;

import java.awt.Color
import java.awt.Component
import java.awt.event.ActionEvent
import java.awt.event.ActionListener
import java.util.concurrent.atomic.AtomicBoolean

import javax.swing.Timer


  def flashFunction(f: Color => Unit, orig: Color, color: Color, flasher: Flasher) {
    def pulse(x: Double) = 7.353 * x * Math.exp(-10 * x * x)
    val max = 200
    if (flasher.flashing.compareAndSet(false, true)) { // Block additional concurrent flashes
      val t = new Timer(4, null)
      t addActionListener new ActionListener() {
        def actionPerformed(evt: ActionEvent) = {
          val p = pulse(flasher.time / max.asInstanceOf[Double])
          val red   = (color.getRed   * p + orig.getRed   * (1 - p)).floor.intValue
          val green = (color.getGreen * p + orig.getGreen * (1 - p)).floor.intValue
          val blue  = (color.getBlue  * p + orig.getBlue  * (1 - p)).floor.intValue
          f (new Color(red, green, blue))
          if (flasher.time < max) flasher.time += 1
          else {
            t setRepeats false
            f (orig)
            flasher.time = 0
            flasher.flashing set false
        }}
        t start
      }
    }
    else flasher.time = 0
  }

} 
开发者ID:janduracz,项目名称:acumen-dev,代码行数:38,代码来源:SwingUtil.scala


示例7: OpenProfileDialog

//设置package包名称以及导入依赖的类
package aug.gui

import java.awt.event.{ActionEvent, ActionListener}
import java.awt.{Dialog, Dimension, FlowLayout}
import javax.swing._

import aug.profile.ConfigManager

class OpenProfileDialog(mainWindow: MainWindow) extends
  JDialog(mainWindow, "Open Profile", Dialog.ModalityType.DOCUMENT_MODAL) {

  setSize(300, 180)
  setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
  setLocationRelativeTo(mainWindow)

  setLayout(new BoxLayout(getContentPane, BoxLayout.Y_AXIS))

  private val profiles: Array[String] = ConfigManager.getUnactivedProfiles.toArray
  val comboBox = new JComboBox[String](profiles)
  val cancelButton = new JButton("cancel")
  val openButton = new JButton("open")

  val flowPanel = new JPanel()
  flowPanel.setLayout(new FlowLayout())
  flowPanel.add(cancelButton)
  flowPanel.add(openButton)

  if(profiles.isEmpty) openButton.setEnabled(false)

  getRootPane.setDefaultButton(openButton)
  getRootPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10))

  comboBox.setMaximumSize(comboBox.getPreferredSize)

  add(comboBox)
  add(Box.createRigidArea(new Dimension(0, 10)))
  add(flowPanel)

  pack()

  cancelButton.addActionListener(new ActionListener {
    override def actionPerformed(e: ActionEvent): Unit = setVisible(false)
  })

  openButton.addActionListener(new ActionListener {
    override def actionPerformed(e: ActionEvent): Unit = {
      ConfigManager.activateProfile(comboBox.getSelectedItem.toString, mainWindow)
      setVisible(false)
    }
  })

  setVisible(true)
} 
开发者ID:austinmiller,项目名称:augustmc,代码行数:54,代码来源:OpenProfileDialog.scala



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala Build类代码示例发布时间:2022-05-23
下一篇:
Scala BroadcastReceiver类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap