scala/ScalaBook/chapter-06/hello3.scala

import scala.swing._
import scala.swing.event._

object hello extends SimpleGUIApplication {
  def top = new MainFrame {

    title = "Interactive Window"
    preferredSize = (400,200)
    val close_button = new Button {
      text = "Κλείσιμο"
      font = new java.awt.Font("Verdana", java.awt.Font.BOLD, 22)
    }

    var help_button = new Button {
      text = "Help"
      font = new java.awt.Font("Verdana",java.awt.Font.BOLD, 22)
    }

    val label = new Label {
      text = "Hello World!"
      font = new java.awt.Font("Verdana", java.awt.Font.BOLD, 22)
    }

    contents = new GridBagPanel {
      var c = new Constraints
      c.gridwidth = java.awt.GridBagConstraints.REMAINDER
      c.weightx = 1.0
      add(label, c)
      add(Swing.VStrut(20), c)
      c.fill = GridBagPanel.Fill.None
      c.gridwidth = java.awt.GridBagConstraints.RELATIVE
      add(help_button, c)
      c.gridwidth = java.awt.GridBagConstraints.REMAINDER
      add(close_button, c)
      border = Swing.EmptyBorder(30, 30, 30, 30)
    }

    listenTo(help_button)

    reactions += {
      case ButtonClicked(b1) => new Frame {
        title = "Help Window"
        visible = true

        val close_button2 = new Button { 
          text = "Close" 
          font = new java.awt.Font("Verdana", java.awt.Font.BOLD, 22)
        }
        
        val help_text = new TextArea {
          editable = false
          text = "Click the «Κλείσιμο» button to shut down the application." 
          font = new java.awt.Font("Verdana", java.awt.Font.PLAIN, 20)
        }
        
        contents = new GridBagPanel {
          var d = new Constraints
          d.gridwidth = java.awt.GridBagConstraints.REMAINDER
          add(help_text, d)
          add(close_button2, d)
          border = Swing.EmptyBorder(30, 30, 10, 30)
        }
        
        listenTo(close_button2)
        reactions += { case ButtonClicked(b3) => dispose() }   
      }
    }

    listenTo(close_button)

    reactions += { case ButtonClicked(b2) => if(b2.eq(close_button)) exit(0) }
  }
}