|
用Applet写的菜单程序 machine(2) // This is the color to paint "behind" the image. Color bgColor;
// [0] is the text color of a menu item; [1] is the text color of a highlig hted // menu item. Color fgMenUColor[] = new Color[2];
// This is the background of a menu item; [1] is the background color of a // highlighted menu item. Color bgMenuColor[] = new Color[2];
// marginH is the number of pixels on the left and right edges of the menu. // marginV is the number of pixels on the top and bottom edges of the menu. int marginH, marginV;
// This is the font used to display the menu item labels. Font f;
// This is the font metrics of 'f'. FontMetrics fm;
public void init() { int[] ints;
// Grab applet parameters. image = getImage(getCodeBase(), getParameter("image")); marginH = Integer.parseInt(getParameter("marginh")); marginV = Integer.parseInt(getParameter("marginv"));
// Get color parameters. ints = parseInt(getParameter("bg-color"), " "); bgColor = new Color(ints[0], ints[1], ints[2]); ints = parseInt(getParameter("fg-menu-color"), " "); fgMenuColor[0] = new Color(ints[0], ints[1], ints[2]); ints = parseInt(getParameter("fg-hi-menu-color"), " "); fgMenuColor[1] = new Color(ints[0], ints[1], ints[2]); ints = parseInt(getParameter("bg-menu-color"), " "); bgMenuColor[0] = new Color(ints[0], ints[1], ints[2]); ints = parseInt(getParameter("bg-hi-menu-color"), " "); bgMenuColor[1] = new Color(ints[0], ints[1], ints[2]);
// Create back buffer for double-buffering. bbuf = createImage(size().width, size().height); bbufG = bbuf.getGraphics();
// Determine the font from the font-height. int fh = Integer.parseInt(getParameter("font-height")); int i = fh; while (i > 10) { f = new Font(getParameter("font"), Font.PLAIN, i); fm = getFontMetrics(f);
|