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

Scala JFrame类代码示例

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

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



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

示例1: Tela

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

import java.awt.{ Canvas, Dimension }

import br.edu.ifrn.potigol.Potigolutil.{ Inteiro, Texto }
import javax.swing.JFrame

class Tela(titulo: Texto, largura: Inteiro, altura: Inteiro) {
  private[this] val dim = new Dimension(largura, altura)
  val canvas = new Canvas() {
    setPreferredSize(dim)
    setMaximumSize(dim)
    setMinimumSize(dim)
    setFocusable(false)
  }
  val frame = new JFrame(titulo) {
    setIconImage(Imagem("potigol.png").buffer)
    setSize(dim)
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    setResizable(false)
    setLocationRelativeTo(null)
    setVisible(true)
    add(canvas)
    pack()
  }
} 
开发者ID:potigol,项目名称:Jerimum,代码行数:27,代码来源:Tela.scala


示例2: MNISTVisualizer

//设置package包名称以及导入依赖的类
package org.dl4scala.examples.feedforward.anomalydetection

import java.awt.{GridLayout, Image}
import java.awt.image.BufferedImage
import javax.swing.{ImageIcon, JFrame, JLabel, JPanel}

import org.nd4j.linalg.api.ndarray.INDArray

import scala.collection.mutable.ArrayBuffer


class MNISTVisualizer(imageScale: Double, digits: ArrayBuffer[INDArray], title: String, gridWidth: Int) {
  def this(imageScale: Double, digits: ArrayBuffer[INDArray], title: String) = {
    this(imageScale, digits, title, 5)
  }

  def visualize(): Unit = {
    val frame = new JFrame
    frame.setTitle(title)
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    val panel = new JPanel
    panel.setLayout(new GridLayout(0, gridWidth))
    val list = getComponents
    for (image <- list) {
      panel.add(image)
    }
    frame.add(panel)
    frame.setVisible(true)
    frame.pack()
  }

  def getComponents: ArrayBuffer[JLabel] = {
    val images = new ArrayBuffer[JLabel]()
    for (arr <- digits) {
      val bi = new BufferedImage(28, 28, BufferedImage.TYPE_BYTE_GRAY)
      for(i <- 0 until 784) {
        bi.getRaster.setSample(i % 28, i / 28, 0, (255 * arr.getDouble(i)).asInstanceOf[Int])
      }
      val orig = new ImageIcon(bi)
      val imageScaled = orig.getImage.getScaledInstance((imageScale * 28).asInstanceOf[Int],
        (imageScale * 28).asInstanceOf[Int], Image.SCALE_REPLICATE)
      val scaled = new ImageIcon(imageScaled)
      images.append(new JLabel(scaled))
    }
    images
  }
} 
开发者ID:endymecy,项目名称:dl4scala,代码行数:48,代码来源:MNISTVisualizer.scala


示例3: Scatter3D

//设置package包名称以及导入依赖的类
import java.awt.Color
import javax.swing.{JFrame, JPanel, WindowConstants}

import org.math.plot._

object Scatter3D {
  def loadDataFromCSV(csvPath: String): JPanel = {
    val data = scala.io.Source.fromFile(csvPath).getLines().map(_.split(",").map(_.trim.toDouble).toSeq)
    val (x, y, z) = (data map {
      case Seq(x_, y_, z_) => (x_, y_, z_)
    }).toArray.unzip3
    val colors = z map (x => new Color(Color.HSBtoRGB(x.toFloat, 1.0f, 0.5f)))
    val plot = new Plot3DPanel()
    plot.addScatterPlot("Fractal in 3D", colors, x, y, z)
    plot
  }

  def main(args: Array[String]): Unit = {
    val plot = loadDataFromCSV(args.headOption.getOrElse("D:/Programming/Projects/FractalGenerator/output.csv"))
    val frame = new JFrame("Fractal3D")
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
    frame.setSize(900, 900)
    frame.setContentPane(plot)
    frame.setVisible(true)
  }
} 
开发者ID:tamchow,项目名称:ScalaStuff,代码行数:27,代码来源:Scatter3D.scala


示例4: Window

//设置package包名称以及导入依赖的类
import java.awt.BorderLayout
import java.awt.BorderLayout.{CENTER, PAGE_END, PAGE_START}
import javax.swing.JFrame.EXIT_ON_CLOSE
import javax.swing.{JFrame, ImageIcon, JLabel, JPanel, BorderFactory}


class Window extends JFrame with StatusChangeCallback {

  private val instructions = "<html><br>'m' - Exit<br>'z' - Start<br>'x' - Stop<br>'p' - Play/Pause</html>"
  private val icon = new ImageIcon("src/main/resources/mch.png")
  private val lblLogo = new JLabel(icon)
  private val lblStatus = new JLabel("Waiting")
  private val panel = new JPanel()
  private val lblInstructions = new JLabel(instructions)

  setDefaultCloseOperation(EXIT_ON_CLOSE)
  setTitle("MyClickHolder")
  setResizable(false)
  setIconImage(icon.getImage)

  panel.setLayout(new BorderLayout())
  panel.setBorder(BorderFactory.createEmptyBorder(50, 50, 50, 50))
  panel.add(lblLogo, PAGE_START)
  panel.add(lblStatus, CENTER)
  panel.add(lblInstructions, PAGE_END)

  add(panel)

  pack()
  setVisible(true)

  override def statusChanged(status: String): Unit = {
    lblStatus.setText(status)
  }

  override def engineExit(): Unit = {
    System.exit(0)
  }
} 
开发者ID:gabrsar,项目名称:MyClickHolder,代码行数:40,代码来源:Window.scala


示例5: Game

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

import java.awt.image.BufferedImage
import java.awt._
import javax.swing.JFrame

class Game(
  frame: JFrame
) extends Loop {
  name = frame.getName
  val image = new BufferedImage(frame.getWidth, frame.getHeight, BufferedImage.TYPE_INT_RGB);
  val canvas = new Canvas()
  canvas.setPreferredSize(frame.getPreferredSize)
  canvas.setMinimumSize(frame.getMinimumSize)
  canvas.setMaximumSize(frame.getMaximumSize)
  frame.add(canvas)
  canvas.requestFocus()
  start()

  def update() = println("tick")

  override def render(): Unit = {
    val bs = canvas.getBufferStrategy
    if (bs == null) {
      canvas.createBufferStrategy(3)
      return
    }

    val g2d = image.getGraphics
    g2d.setColor(Color.WHITE)
    g2d.clearRect(0, 0, canvas.getWidth, canvas.getHeight)
    g2d.setColor(Color.BLACK)
    g2d.drawString("Heisann", 10, 10)

    val g = bs.getDrawGraphics
    g.drawImage(image, 0, 0, canvas.getWidth, canvas.getHeight, null)
    Toolkit.getDefaultToolkit.sync()
    g.dispose()
    bs.show()
  }
}

object Game extends App {
  val frame = new JFrame("Test")
  val gameDimension = new Dimension(500, 500)
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
  frame.setMinimumSize(gameDimension)
  frame.setPreferredSize(gameDimension)
  frame.setMaximumSize(gameDimension)
  frame.setVisible(true)
  val game = new Game(frame)
} 
开发者ID:jarlah,项目名称:2d-game,代码行数:53,代码来源:Game.scala


示例6: Main

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

import java.awt.Color
import javax.swing.JFrame
import data.Cfg
import view.Animation

object Main extends App {
  def run() {
    val anima = Animation(1 / 30d)
    val frame = new JFrame()
    frame.getContentPane.add(anima)
    frame.setBackground(Color.gray)
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
    frame.setSize(Cfg.frameWidth, Cfg.frameHeight)
    frame.setVisible(true)
    while (true) {
      anima.update()
      frame.repaint()
    }
  }

  run()
} 
开发者ID:davips,项目名称:mucel-scala,代码行数:25,代码来源:Main.scala


示例7: TestNext

//设置package包名称以及导入依赖的类
import java.awt.Dimension
import javax.swing.JFrame

import com.alee.laf.WebLookAndFeel
import com.sun.awt.AWTUtilities

import scala.swing.SimpleSwingApplication

object TestNext extends SimpleSwingApplication with AppMixin {
  WebLookAndFeel.install()

  def title = "Next"

  override def startup(args: Array[String]): Unit = {
    JFrame.setDefaultLookAndFeelDecorated(true)
//    super.startup(args)
    val t = top
    AWTUtilities.setWindowOpaque ( t.peer, false )
    // t.peer.setUndecorated(true)
    t.peer.getRootPane.putClientProperty("styleId", "frame-decorated")
    // if (t.size == new Dimension(0,0))
    t.pack()
    t.centerOnScreen()
    t.visible = true
  }
} 
开发者ID:Sciss,项目名称:WebLaF_debug,代码行数:27,代码来源:TestNext.scala


示例8: WindowBorders

//设置package包名称以及导入依赖的类
import java.awt.{EventQueue, Rectangle}
import javax.swing.{JFrame, JLabel, WindowConstants}

import com.alee.laf.WebLookAndFeel

object WindowBorders extends App with Runnable {
  WebLookAndFeel.install()
  JFrame.setDefaultLookAndFeelDecorated(true)
  EventQueue.invokeLater(this)

  def run(): Unit = {
    val t = new JFrame
    t.pack()  // avoid repaint bug when using LaF-decoration
    t.setTitle("Title")
    t.getContentPane.add(new JLabel("Test one two."))
    t.setBounds(new Rectangle(400, 400, 400, 200))
    t.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
    // t.setOpacity(0.99f)
    t.setVisible(true)
  }
} 
开发者ID:Sciss,项目名称:WebLaF_debug,代码行数:22,代码来源:WindowBorders.scala


示例9: TestCurrent

//设置package包名称以及导入依赖的类
import java.awt.Dimension
import javax.swing.JFrame

import com.alee.laf.WebLookAndFeel

import scala.swing.SimpleSwingApplication

object TestCurrent extends SimpleSwingApplication with AppMixin {
  WebLookAndFeel.install()

  def title = "Current"

  override def startup(args: Array[String]): Unit = {
    JFrame.setDefaultLookAndFeelDecorated(true)
//    super.startup(args)
    val t = top
    if (t.size == new Dimension(0,0)) t.pack()
    t.peer.getRootPane.putClientProperty("styleId", "frame-decorated")
    t.visible = true
  }
} 
开发者ID:Sciss,项目名称:WebLaF_debug,代码行数:22,代码来源:TestCurrent.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Scala RouterCtl类代码示例发布时间:2022-05-23
下一篇:
Scala jQuery类代码示例发布时间: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