0
Я пытаюсь создать приложение, в котором вы можете пролистывать страницы.Новичок пытается отобразить два изображения рядом с помощью Scala.Swing
Я надеялся, что этот код будет отображать два изображения (001.jpg, 002.jpg) рядом, но вместо этого я ничего не получаю.
import java.awt.Dimension
import javax.swing.ImageIcon
import scala.swing.event.UIElementResized
import scala.swing.{BorderPanel, BoxPanel, Label, MainFrame, Orientation, SimpleSwingApplication}
object CViewerMainWindow extends SimpleSwingApplication {
var i = 0
def drawPages(left: Label, right: Label, size: Dimension): Unit = {
//resize to match window
}
def top = new MainFrame {
title = "Work in Progress"
preferredSize = new Dimension(320, 240)
var leftPage = new Label {new ImageIcon("/Users/Matt/learning-scala/learning-GUI/001.jpg")}
var rightPage = new Label {new ImageIcon("/Users/Matt/learning-scala/learning-GUI/002.jpg")}
// maximize
visible = true
// contents = new BorderPanel {
// layout(leftPage) = BorderPanel.Position.West
// layout(rightPage) = BorderPanel.Position.East
// }
contents = new BorderPanel {
layout(new BoxPanel(Orientation.Vertical) {
contents += leftPage
}) = BorderPanel.Position.West
layout(new BoxPanel(Orientation.Vertical) {
contents += rightPage
}) = BorderPanel.Position.East
}
// contents = new Label("Here is the contents!")
listenTo(this)
reactions += {
case UIElementResized(source) =>
println(source.size)
drawPages(leftPage, rightPage, size)
}
}
}