Show
Ignore:
Timestamp:
01/29/08 16:45:49 (6 years ago)
Author:
kmizu
Message:

add usage

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/scala/sandbox/src/jp/gr/java_conf/mizu/gui/Listeners.scala

    r5785 r5786  
    11package jp.gr.java_conf.mizu.gui 
     2 
     3import java.awt._ 
     4import java.awt.event._ 
    25 
    36object Listeners { 
     
    191194    def windowOpened(e :java.awt.event.WindowEvent) { } 
    192195  } 
     196 
    193197  def windowOpened(proc :java.awt.event.WindowEvent => unit) = new java.awt.event.WindowListener { 
    194198    def windowActivated(e :java.awt.event.WindowEvent) { } 
     
    200204    def windowOpened(e :java.awt.event.WindowEvent) { proc(e) } 
    201205  } 
     206 
    202207  def windowStateChanged(proc :java.awt.event.WindowEvent => unit) = new java.awt.event.WindowStateListener { 
    203208    def windowStateChanged(e :java.awt.event.WindowEvent) { proc(e) } 
    204209  } 
     210 
     211  //Usage 
     212        def main(args: Array[String]) { 
     213          import javax.swing._ 
     214                val frame = new JFrame("Example Frame") 
     215                val button = new JButton("Exit") 
     216                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) 
     217                frame.getContentPane.add(button) 
     218                button addActionListener actionPerformed{e => 
     219                  exit(-1) 
     220                } 
     221                frame.pack 
     222                frame.setVisible(true) 
     223        } 
    205224}