浏览代码

System Look-and-Feel

frans 8 年之前
父节点
当前提交
c2952b7081
共有 1 个文件被更改,包括 19 次插入3 次删除
  1. 19 3
      src/main/java/eu/tankernn/grid/GridControl.java

+ 19 - 3
src/main/java/eu/tankernn/grid/GridControl.java

@@ -16,6 +16,8 @@ import java.util.Arrays;
 
 import javax.imageio.ImageIO;
 import javax.swing.JFrame;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
 
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
@@ -124,7 +126,9 @@ public class GridControl implements Runnable {
 		}
 		// Save misc. settings
 		try (Writer writer = new FileWriter(SETTINGS_PATH)) {
-			gson.toJson(new Settings(model.getGrid().getCommunicator().getPortName(), model.getGrid().fanStream().map(f -> f.getProfile().name).toArray(String[]::new), pollingSpeed, model.getMinSpeed()), writer);
+			gson.toJson(new Settings(model.getGrid().getCommunicator().getPortName(),
+					model.getGrid().fanStream().map(f -> f.getProfile().name).toArray(String[]::new), pollingSpeed,
+					model.getMinSpeed()), writer);
 		} catch (IOException e) {
 			e.printStackTrace();
 		}
@@ -146,14 +150,26 @@ public class GridControl implements Runnable {
 				return;
 			}
 		}
-
 	}
 
 	/**
 	 * 
-	 * @param args the command line arguments
+	 * @param args
+	 *            the command line arguments
 	 */
 	public static void main(String[] args) {
+		try {
+			// Set System L&F
+			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+		} catch (UnsupportedLookAndFeelException e) {
+			// handle exception
+		} catch (ClassNotFoundException e) {
+			// handle exception
+		} catch (InstantiationException e) {
+			// handle exception
+		} catch (IllegalAccessException e) {
+			// handle exception
+		}
 		new GridControl(!Arrays.asList(args).contains("nogui"));
 	}