001package ca.bc.webarts.applets.menu; 002 003import java.applet.*; 004import java.awt.*; 005import java.io.*; 006import java.net.*; 007 008public class MyMenu extends Applet 009{ 010 public PropertiesMenu propt; 011 public AudioClip click; 012 public AudioClip pop; 013 014 public String getAppletInfo() 015 { 016 return "Web Menu"; 017 } 018 019 public void init() 020 { 021 String string = this.getParameter("configFile"); 022 if (string == null) 023 string = "config.txt"; 024 //System.out.println("Init with Config File "+string); 025 try 026 { 027 propt = new PropertiesMenu(); 028 URL url = new URL(this.getCodeBase() + string); 029 System.out.println("Init Config file = "+this.getCodeBase() + string); 030 BufferedInputStream bufferedinputstream 031 = new BufferedInputStream(url.openStream()); 032 propt.load(bufferedinputstream); 033 bufferedinputstream.close(); 034 //System.out.println("menu1 = " +propt.getProperty("menu1")); 035 //propt.list(System.out); 036 //Object object = null; 037 } 038 catch (Exception exception) 039 { 040 exception.printStackTrace(); 041 this.showStatus("Error reading album.cfg" + exception); 042 } 043 int fontStyle = Font.PLAIN; 044 String fontStyleStr = propt.getProperty("fontStyle","PLAIN"); 045 if (fontStyleStr.toUpperCase().equals("BOLD")) 046 fontStyle = Font.BOLD; 047 else if (fontStyleStr.toUpperCase().equals("ITALIC")) 048 fontStyle = Font.ITALIC; 049 this.setBackground(parseColor(propt.getProperty("bgColor", "#0055cc"))); 050 this.setForeground(parseColor(propt.getProperty("fgColor", "black"))); 051 this.setFont(new Font(propt.getProperty("fontName", "Sans-serif"), 052 fontStyle, 053 Integer.parseInt(propt.getProperty("fontSize","12")) 054 )); 055 this.setLayout(new BorderLayout(0, 0)); 056 this.add("Center", new MyMainMenuPanel(this)); 057 //System.out.println("Added MyMainMenuPanel"); 058 click = this.getAudioClip(this.getCodeBase(), "menu/au/button.au"); 059 pop = this.getAudioClip(this.getCodeBase(), "menu/au/pop.au"); 060 } 061 062private Color parseColor(String string) 063{ 064 if (string.charAt(0) == '#') { 065 String string_0_ = string.substring(1, 3); 066 String string_1_ = string.substring(3, 5); 067 String string_2_ = string.substring(5, 7); 068 int i = Integer.parseInt(string_0_, 16); 069 int i_3_ = Integer.parseInt(string_1_, 16); 070 int i_4_ = Integer.parseInt(string_2_, 16); 071 return new Color(i, i_3_, i_4_); 072 } 073 return toColor(string); 074 } 075 076 private Color toColor(String string) { 077 if (string.equals("black")) 078 return Color.black; 079 if (string.equals("orange")) 080 return Color.orange; 081 if (string.equals("red")) 082 return Color.red; 083 if (string.equals("green")) 084 return Color.green; 085 if (string.equals("blue")) 086 return Color.blue; 087 if (string.equals("cyan")) 088 return Color.cyan; 089 if (string.equals("magenta")) 090 return Color.magenta; 091 if (string.equals("gray")) 092 return Color.gray; 093 return Color.white; 094 } 095 096 public static void main(String[] arg) 097 { 098 } 099}