sane platform look-and-feel;
authorwenzelm
Sun, 28 Jun 2009 16:46:00 +0200
changeset 31828 31584cf201cc
parent 31827 b54362b9fbef
child 31829 6906e114c898
sane platform look-and-feel;
src/Pure/System/gui_setup.scala
src/Pure/System/platform.scala
--- a/src/Pure/System/gui_setup.scala	Sun Jun 28 16:01:52 2009 +0200
+++ b/src/Pure/System/gui_setup.scala	Sun Jun 28 16:46:00 2009 +0200
@@ -6,12 +6,23 @@
 
 package isabelle
 
+import javax.swing.UIManager
+
 import scala.swing._
 import scala.swing.event._
 
 
-object GUI_Setup extends SimpleGUIApplication
+object GUI_Setup extends GUIApplication
 {
+  def main(args: Array[String]) =
+  {
+    Swing.later {
+      UIManager.setLookAndFeel(Platform.look_and_feel)
+      top.pack()
+      top.visible = true
+    }
+  }
+
   def top = new MainFrame {
     title = "Isabelle setup"
     val ok = new Button { text = "OK" }
--- a/src/Pure/System/platform.scala	Sun Jun 28 16:01:52 2009 +0200
+++ b/src/Pure/System/platform.scala	Sun Jun 28 16:46:00 2009 +0200
@@ -6,14 +6,21 @@
 
 package isabelle
 
+import javax.swing.UIManager
+
 import scala.util.matching.Regex
 
 
 object Platform
 {
+  /* main OS variants */
+
   val is_macos = System.getProperty("os.name") == "Mac OS X"
   val is_windows = System.getProperty("os.name").startsWith("Windows")
 
+
+  /* Isabelle platform identifiers */
+
   private val Solaris = new Regex("SunOS|Solaris")
   private val Linux = new Regex("Linux")
   private val Darwin = new Regex("Mac OS X")
@@ -44,5 +51,19 @@
       case None => None
     }
   }
+
+
+  /* Swing look-and-feel */
+
+  def look_and_feel(): String =
+  {
+    if (is_windows || is_macos) UIManager.getSystemLookAndFeelClassName()
+    else {
+      UIManager.getInstalledLookAndFeels().find(laf => laf.getName == "Nimbus") match {
+        case None => UIManager.getCrossPlatformLookAndFeelClassName()
+        case Some(laf) => laf.getClassName
+      }
+    }
+  }
 }