fonts changed as selection made
authoramwaterhouse <Andrew Waterhouse>
Thu, 10 Mar 2005 10:12:01 +0000 (10:12 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 10 Mar 2005 10:12:01 +0000 (10:12 +0000)
src/jalview/gui/FontChooser.java

index 782d2d6..d7a88a7 100755 (executable)
@@ -12,11 +12,13 @@ public class FontChooser extends GFontChooser
 {\r
   AlignmentPanel ap;\r
   Font oldFont;\r
+  boolean init = true;\r
+  JInternalFrame frame;\r
 \r
-  public FontChooser(AlignmentPanel ap)\r
+  public FontChooser(AlignmentPanel ap, JInternalFrame f)\r
   {\r
     this.ap = ap;\r
-\r
+    frame = f;\r
     String fonts[] = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();\r
     for(int i=0; i<fonts.length; i++)\r
       fontName.addItem(fonts[i]);\r
@@ -33,17 +35,18 @@ public class FontChooser extends GFontChooser
    fontSize.setSelectedItem(oldFont.getSize()+"");\r
    fontStyle.setSelectedIndex(oldFont.getStyle());\r
 \r
+   init = false;\r
   }\r
 \r
   protected void ok_actionPerformed(ActionEvent e)\r
   {\r
-    Font newFont = new Font(fontName.getSelectedItem().toString(),\r
-                            fontStyle.getSelectedIndex(),\r
-                            Integer.parseInt(fontSize.getSelectedItem().toString()+"")\r
-                            );\r
-    ap.av.setFont(newFont);\r
-    ap.RefreshPanels();\r
-    ap.RefreshPanels();\r
+    try{\r
+      frame.setClosed(true);\r
+    }catch(Exception ex){}\r
+\r
+   jalview.bin.Cache.setProperty("FONT_NAME", fontName.getSelectedItem().toString());\r
+   jalview.bin.Cache.setProperty("FONT_STYLE", fontStyle.getSelectedIndex()+"");\r
+   jalview.bin.Cache.setProperty("FONT_SIZE", fontSize.getSelectedItem().toString());\r
   }\r
 \r
   protected void cancel_actionPerformed(ActionEvent e)\r
@@ -55,5 +58,33 @@ public class FontChooser extends GFontChooser
     fontStyle.setSelectedIndex(oldFont.getStyle());\r
   }\r
 \r
+  void changeFont()\r
+  {\r
+    Font newFont = new Font(fontName.getSelectedItem().toString(),\r
+                            fontStyle.getSelectedIndex(),\r
+                            Integer.parseInt(fontSize.getSelectedItem().toString())\r
+                            );\r
+    ap.av.setFont(newFont);\r
+    ap.RefreshPanels();\r
+  }\r
+\r
+  protected void fontName_actionPerformed(ActionEvent e)\r
+  {\r
+    if(init) return;\r
+    changeFont();\r
+  }\r
+\r
+  protected void fontSize_actionPerformed(ActionEvent e)\r
+  {\r
+    if(init) return;\r
+    changeFont();\r
+  }\r
+\r
+  protected void fontStyle_actionPerformed(ActionEvent e)\r
+  {\r
+    if(init) return;\r
+    changeFont();\r
+  }\r
+\r
 \r
 }\r