余録:worldCup/scala/ex07/wcFrame.scala

  1: //..+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
  2: 
  3: /* ---------------------------------------- demo: scala
  4: cd /Users/sketch/home_sketch/worldCup/scala/
  5: 
  6: scalac ex07/wcFrame.scala
  7: scala WorldCup
  8: */
  9: 
 10: // ----------------------------------------
 11: import swing._
 12: import swing.event._
 13: 
 14: object WorldCup extends SimpleSwingApplication {
 15:   println("version: #1.0.40")
 16: 
 17:   def top = new MainFrame {
 18:     title = "FIFA World Cup #07"
 19:     contents = TopPanel
 20:   }
 21: }
 22: 
 23: // ----------------------------------------
 24: import javax.swing.ImageIcon
 25: 
 26: object TopPanel extends FlowPanel {
 27:   def _leftComponent = {
 28:     def teams = "ABCDEFGH".split("").tail
 29:     def view = new ListView(teams) {
 30: //      listData = List("A","B","C") //(1 to 9).toList
 31:       reactions += { 
 32:         case ListSelectionChanged(source, range, live) => 
 33:           val items = source.selection.items
 34:           println(":: %s" format items)
 35:       }
 36:       listenTo(this.selection)
 37:     }
 38:     new ScrollPane {
 39:       contents = view
 40:       preferredSize = new Dimension(120,150)
 41:     }
 42:   }
 43: 
 44:   def _rightComponent = {
 45:     def view = new Label {
 46:       icon = new ImageIcon("matches/fifa.png")
 47:     }
 48:     new ScrollPane {
 49:       contents = view
 50:       preferredSize = new Dimension(180,0)
 51:     }
 52:   }
 53:   contents += new SplitPane {
 54:     orientation = Orientation.Vertical
 55:     oneTouchExpandable = true
 56:     dividerLocation = 100
 57:     leftComponent  = _leftComponent
 58:     rightComponent = _rightComponent
 59:   }
 60: }
 61: 
 62: // ========================================