⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menudata.java

📁 这是我在测试手机java时候做的java菜单程序
💻 JAVA
字号:
/*==============================================================================

FILE:  MenuData.java

GENERAL DESCRIPTION:
   Class to contain data for DemoMenu MIDlet.

Copyright (c) 2002 Qualcomm Inc.  All rights reserved.
==============================================================================*/

package com.qualcomm.demo.menu;

import javax.microedition.lcdui.Image;
import java.io.IOException;

/**
 * MenuData class.
 */
public class MenuData
{
   /*===========================================================================
    * Built-in Qualcomm Demos menu data
    *=========================================================================*/

   // Menu data
   static private final MenuItem[] qcDemos =
   {
      new MenuItem( "com.qualcomm.tests.stockchecker.StockChecker"),
      new MenuItem( "com.qualcomm.demo.sound.BBall"),
      new MenuItem( "com.qualcomm.tests.testaudio.AudioMidlet"),
   };

   /*===========================================================================
    * Built-in Qualcomm Tests menu data
    *=========================================================================*/

   // Menu data
   static private final MenuItem[] qcTests =
   {
      new MenuItem( "com.qualcomm.tests.netmidlet.NetMidlet"),
      new MenuItem( "com.qualcomm.tests.LQvmmarkRomized.QVMMark", "LQVMmarkRomized", null),
      new MenuItem( "com.qualcomm.tests.qvmmarkRomized.QVMMark"),
   };

   /*===========================================================================
    * Master array of menus
    *=========================================================================*/

   static private final MenuData[] menus =
   {
      new MenuData( "Built-in Qualcomm Demos", qcDemos ),
      new MenuData( "Built-in Qualcomm Tests", qcTests ),
   };

   /*===========================================================================
    * End of static data
    *=========================================================================*/

   // Name of this menu
   private String name;

   // Menu items associated with this menu
   private MenuItem[] items;

   // Inner class to represent menu item properties
   private static class MenuItemProperty
   {
      // Property key and value
      private String key;
      private String value;

      // Constructor
      MenuItemProperty(String key, String value)
      {
         this.key = key;
         this.value = value;
      }
   }

   // Inner class to represent menu items
   private static class MenuItem
   {
      // MIDlet name, icon, and full class name
      private String classname;
      private String name;
      private Image icon;
      private MenuItemProperty[] properties;

      // Constructor
      MenuItem(String classname, String name, String iconPath,
               MenuItemProperty[] properties)
      {
         this.classname = classname;
         this.properties = properties;

         // Get default name from classname if no name provided
         if (name == null)
         {
            this.name = classname.substring(classname.lastIndexOf('.') + 1);
         }
         else
         {
            this.name = name;
         }

         // Use default icon if none provided
         if (iconPath == null)
         {
            if (classname.indexOf("qualcomm") >= 0)
            {
               // Default icon for classes containing "qualcomm"
               icon = MenuDataIcons.qcDefaultIcon;
            }
         }

         // Store icon as Image created from given path
         if (iconPath != null)
         {
            try
            {
               icon = Image.createImage(iconPath);
            }
            catch (IOException e)
            {
               System.out.println("Cannot create icon " + iconPath);
            }
         }
      }

      // Constructor with no properties
      MenuItem(String classname, String name, String iconPath)
      {
         this(classname, name, iconPath, null);
      }

      // Constructor with default icon and name
      MenuItem(String classname, MenuItemProperty[] properties)

      {
         this(classname, null, null, properties);
      }

      // Constructor with default icon and name and no properties
      MenuItem(String classname)
      {
         this(classname, null, null, null);
      }
   }

   // Constructor
   private MenuData(String name, MenuItem[] items)
   {
      this.name = name;
      this.items = items;
   }

   // Returns number of menus stored in this class.
   static int getNumMenus()
   {
      return menus.length;
   }

   // Returns specified menu instance.
   static MenuData getMenu(int i)
   {
      return menus[i];
   }

   // Returns name of this menu instance.
   String getName()
   {
      return name;
   }

   // Returns number of items in this menu instance.
   int getNumItems()
   {
      return items.length;
   }

   // Returns classname of specified item in this menu instance.
   String getItemClassname(int i)
   {
      return items[i].classname;
   }

   // Returns name of specified item in this menu instance.
   String getItemName(int i)
   {
      return items[i].name;
   }

   // Returns icon of specified item in this menu instance.
   Image getItemIcon(int i)
   {
      return items[i].icon;
   }

   // Returns number of properties for specified item in this menu instance.
   int getItemNumProperties(int i)
   {
      return (items[i].properties == null) ? 0 : items[i].properties.length;
   }

   // Returns key name of specified property for specified item in this menu
   // instance.
   String getItemPropertyKey(int i, int j)
   {
      return items[i].properties[j].key;
   }

   // Returns value of specified property for specified item in this menu
   // instance.
   String getItemPropertyValue(int i, int j)
   {
      return items[i].properties[j].value;
   }
}

// Class to hold "hardcoded" images
class MenuDataIcons
{
   // Image for QC default icon (from qc_icon.png)
   static private byte[] qcDefaultIconData =
   {
      (byte)0x89, (byte)0x50, (byte)0x4e, (byte)0x47, (byte)0x0d, (byte)0x0a,
      (byte)0x1a, (byte)0x0a, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x0d,
      (byte)0x49, (byte)0x48, (byte)0x44, (byte)0x52, (byte)0x00, (byte)0x00,
      (byte)0x00, (byte)0x0c, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x0c,
      (byte)0x08, (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xd9,
      (byte)0x17, (byte)0xcb, (byte)0xb0, (byte)0x00, (byte)0x00, (byte)0x00,
      (byte)0x5f, (byte)0x49, (byte)0x44, (byte)0x41, (byte)0x54, (byte)0x78,
      (byte)0x9c, (byte)0x8d, (byte)0x90, (byte)0x4b, (byte)0x0e, (byte)0xc0,
      (byte)0x40, (byte)0x08, (byte)0x42, (byte)0xb1, (byte)0xe9, (byte)0xbd,
      (byte)0x0b, (byte)0x27, (byte)0xa7, (byte)0x0b, (byte)0x27, (byte)0xce,
      (byte)0x27, (byte)0xe9, (byte)0x4c, (byte)0x59, (byte)0xa9, (byte)0xbc,
      (byte)0x18, (byte)0x31, (byte)0x6c, (byte)0xe3, (byte)0xa4, (byte)0xbb,
      (byte)0xaa, (byte)0x08, (byte)0x8d, (byte)0x86, (byte)0xfd, (byte)0x74,
      (byte)0x2b, (byte)0x37, (byte)0x25, (byte)0x41, (byte)0x36, (byte)0x83,
      (byte)0xd4, (byte)0xc4, (byte)0xd9, (byte)0x06, (byte)0x08, (byte)0x90,
      (byte)0x74, (byte)0x89, (byte)0x6c, (byte)0xc3, (byte)0x6c, (byte)0x1b,
      (byte)0x34, (byte)0x12, (byte)0x23, (byte)0x97, (byte)0xf5, (byte)0x75,
      (byte)0xbc, (byte)0x1a, (byte)0xc0, (byte)0x0a, (byte)0x49, (byte)0x6b,
      (byte)0x82, (byte)0x0e, (byte)0x91, (byte)0x92, (byte)0x26, (byte)0x34,
      (byte)0x6f, (byte)0xff, (byte)0x4c, (byte)0x57, (byte)0x76, (byte)0xa5,
      (byte)0x8b, (byte)0x7a, (byte)0xe6, (byte)0xe6, (byte)0x4f, (byte)0xd8,
      (byte)0x84, (byte)0x2a, (byte)0xfd, (byte)0x4a, (byte)0xf7, (byte)0x02,
      (byte)0x4b, (byte)0x1a, (byte)0x79, (byte)0xc3, (byte)0xcf, (byte)0xec,
      (byte)0xf3, (byte)0xaf, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
      (byte)0x49, (byte)0x45, (byte)0x4e, (byte)0x44, (byte)0xae, (byte)0x42,
      (byte)0x60, (byte)0x82
   };
   static Image qcDefaultIcon =
      Image.createImage(qcDefaultIconData, 0, qcDefaultIconData.length);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -