src/Pure/library.scala
changeset 47868 395b7277ed76
parent 47594 54ea872b60ea
child 48738 dd9cbe708e6b
equal deleted inserted replaced
47867:f1856425224e 47868:395b7277ed76
   128   }
   128   }
   129 
   129 
   130 
   130 
   131   /* simple dialogs */
   131   /* simple dialogs */
   132 
   132 
   133   private def simple_dialog(kind: Int, default_title: String)
   133   private def simple_dialog(kind: Int, default_title: String,
   134     (parent: Component, title: String, message: Any*)
   134     parent: Component, title: String, message: Seq[Any])
   135   {
   135   {
   136     Swing_Thread.now {
   136     Swing_Thread.now {
   137       val java_message = message map { case x: scala.swing.Component => x.peer case x => x }
   137       val java_message = message map { case x: scala.swing.Component => x.peer case x => x }
   138       JOptionPane.showMessageDialog(parent,
   138       JOptionPane.showMessageDialog(parent,
   139         java_message.toArray.asInstanceOf[Array[AnyRef]],
   139         java_message.toArray.asInstanceOf[Array[AnyRef]],
   140         if (title == null) default_title else title, kind)
   140         if (title == null) default_title else title, kind)
   141     }
   141     }
   142   }
   142   }
   143 
   143 
   144   def dialog = simple_dialog(JOptionPane.PLAIN_MESSAGE, null) _
   144   def dialog(parent: Component, title: String, message: Any*) =
   145   def warning_dialog = simple_dialog(JOptionPane.WARNING_MESSAGE, "Warning") _
   145     simple_dialog(JOptionPane.PLAIN_MESSAGE, null, parent, title, message)
   146   def error_dialog = simple_dialog(JOptionPane.ERROR_MESSAGE, "Error") _
   146 
       
   147   def warning_dialog(parent: Component, title: String, message: Any*) =
       
   148     simple_dialog(JOptionPane.WARNING_MESSAGE, "Warning", parent, title, message)
       
   149 
       
   150   def error_dialog(parent: Component, title: String, message: Any*) =
       
   151     simple_dialog(JOptionPane.ERROR_MESSAGE, "Error", parent, title, message)
   147 
   152 
   148   def confirm_dialog(parent: Component, title: String, option_type: Int, message: Any*): Int =
   153   def confirm_dialog(parent: Component, title: String, option_type: Int, message: Any*): Int =
   149     Swing_Thread.now {
   154     Swing_Thread.now {
   150       val java_message = message map { case x: scala.swing.Component => x.peer case x => x }
   155       val java_message = message map { case x: scala.swing.Component => x.peer case x => x }
   151       JOptionPane.showConfirmDialog(parent,
   156       JOptionPane.showConfirmDialog(parent,