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

📄 uiaccess.java

📁 j2me is based on j2mepolish, client & server for mobile application. menu sample
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		}
		return itemAttributes.get( key );
	}
	//#endif
  
	//#if polish.midp
  /**
   * Returns a HashMap object with all registered attributes.
   * 
   * @param item the item from which the attributes should be retrieved
   * @return a HashMap object with all attribute key/value pairs, null if no attribute was stored before.
   */
  public static HashMap getAttributes( javax.microedition.lcdui.Item item ) {
    if ( attributes == null ) {
      return null;
    }
    return (HashMap) attributes.get( item );
  }
  //#endif
  
//#if polish.midp
	/**
	 * Sets an arbitrary attribute for the specified list item.
	 * 
   * @param list a list of items
	 * @param index the index of the item to which the attribute should be added
	 * @param key the key for the attribute
	 * @param value the attribute value
	 */
	public static void setAttribute( javax.microedition.lcdui.List list, int index, Object key, Object value ) {
		if (attributes == null) {
			attributes = new HashMap();
		}
		String item = list.toString() + index;
		HashMap itemAttributes = (HashMap) attributes.get( item );
		if (itemAttributes == null) {
			itemAttributes = new HashMap();
			attributes.put( item, itemAttributes );
		}
		itemAttributes.put( key, value );
	}
//#endif
	
//#if polish.midp
	/**
	 * Gets an previously added attribute of the specified item.
	 * 
   * @param list a list of items
   * @param index the index of item from which the attributes should be retrieved
	 * @param key the key of the attribute
	 * @return the attribute value, null if none has been registered under the given key before
	 */
	public static Object getAttribute( javax.microedition.lcdui.List list, int index, Object key ) {
		if ( attributes == null ) {
			return null;
		}
		String item = list.toString() + index;
		HashMap itemAttributes = (HashMap) attributes.get( item );
		if (itemAttributes == null) {
			return null;
		}
		return itemAttributes.get( key );
	}
//#endif
	
	//#if polish.midp
	/**
	 * Returns a HashMap object with all registered attributes.
	 * 
   * @param list a list of items
	 * @param index the index of the item from which the attributes should be retrieved
	 * @return a HashMap object with all attribute key/value pairs, null if no attribute was stored before.
	 */
	public static HashMap getAttributes( javax.microedition.lcdui.List list, int index ) {
	    if ( attributes == null ) {
	        return null;
	      }
	    String item = list.toString() + index;
	    return (HashMap) attributes.get( item );
	}
	//#endif

	//#if polish.midp
	/**
	 * Makes the item interactive (accessible) or non-interactive.
	 * This method is ignored when the J2ME Polish UI is not activated.
	 * <pre>
	 * //#style inactiveStyle
	 * UiAccess.setAccessible( myItem, false );
	 * </pre>
	 * 
	 * @param item the item that should be made accessible 
	 * @param isAccessible true when the item should be accessible/selectable
	 */
	public static void setAccessible( javax.microedition.lcdui.Item item, boolean isAccessible ) {
		// ignore
	}
	//#endif
	
	//#if polish.usePolishGui
	/**
	 * Makes the item interactive (accessible) or non-interactive.
	 * You can set a new style at the same time by adding a style directive:
	 * <pre>
	 * //#style inactiveStyle
	 * UiAccess.setAccessible( myItem, false );
	 * </pre>
	 * 
	 * @param item the item that should be made accessible 
	 * @param isAccessible true when the item should be accessible/selectable
	 */
	public static void setAccessible( Item item, boolean isAccessible ) {
		if (isAccessible) {
			item.setAppearanceMode( Item.INTERACTIVE );
		} else {
			item.setAppearanceMode( Item.PLAIN );
		}
	}
	//#endif
	
	//#if polish.usePolishGui
	/**
	 * Makes the item interactive (accessible) or non-interactive.
	 * You can set a new style at the same time by adding a style directive:
	 * <pre>
	 * //#style inactiveStyle
	 * UiAccess.setAccessible( myItem, false );
	 * </pre>
	 * 
	 * @param item the item that should be made accessible 
	 * @param isAccessible true when the item should be accessible/selectable
	 * @param style the new style, is ignored when it is null
	 */
	public static void setAccessible( Item item, boolean isAccessible, Style style ) {
		if (!isAccessible && item.isFocused) {
			// first defocus item:
			Item parent = item.parent;
			if (parent instanceof Container) {
				((Container)parent).focus(-1);
			}
		}
		if (style != null) {
			item.setStyle(style);
		}
		if (isAccessible) {
			item.setAppearanceMode( Item.INTERACTIVE );
		} else {
			item.setAppearanceMode( Item.PLAIN );
		}
	}
	//#endif
	
	//#if polish.midp
	/**
	 * Applies a style to the specified list item.
	 * 
	 * @param list the list 
	 * @param itemIndex the index of the list
	 */
	public static void setAccessible(javax.microedition.lcdui.List list, int itemIndex, boolean isAccessible) {
		// ignore
	}
	//#endif	

	//#if polish.usePolishGui
	/**
	 * Applies a style to the specified list item.
	 * 
	 * @param list the list 
	 * @param itemIndex the index of the list
	 * @param isAccessible true when the item should be accessible/selectable
	 */
	public static void setAccessible(List list, int itemIndex, boolean isAccessible) {
		setAccessible(list.getItem(itemIndex), isAccessible);
	}
	//#endif	

	//#if polish.usePolishGui
	/**
	 * Applies a style to the specified list item.
	 * 
	 * @param list the list 
	 * @param itemIndex the index of the list
	 * @param isAccessible true when the item should be accessible/selectable
	 * @param style the new style of the item
	 */
	public static void setAccessible(List list, int itemIndex, boolean isAccessible, Style style) {
		setAccessible( list.getItem(itemIndex), isAccessible, style );
	}
	//#endif	
	
	//#if polish.midp
	/**
	 * Makes the command interactive (accessible) or non-interactive.
	 * This method is ignored when the J2ME Polish UI is not activated.
	 * <pre>
	 * //#style inactiveStyle
	 * UiAccess.setAccessible( myScreen, myCommand, false );
	 * </pre>
	 * 
	 * @param screen the screen that contains the command
	 * @param command the item that should be made accessible 
	 * @param isAccessible true when the item should be accessible/selectable
	 */
	public static void setAccessible( javax.microedition.lcdui.Screen screen, Command command, boolean isAccessible ) {
		// ignore
	}
	//#endif
	
	//#if polish.usePolishGui
	/**
	 * Makes the item interactive (accessible) or non-interactive.
	 * <pre>
	 * //#style inactiveStyle
	 * UiAccess.setAccessible( myScreen, myCommand, false );
	 * </pre>
	 * 
	 * @param screen the screen that contains the command
	 * @param command the item that should be made accessible 
	 * @param isAccessible true when the item should be accessible/selectable
	 */
	public static void setAccessible( Screen screen, Command command, boolean isAccessible ) {
		setAccessible( screen.getCommandItem(command), isAccessible );
	}
	//#endif
	
	//#if polish.usePolishGui
	/**
	 * Makes the item interactive (accessible) or non-interactive.
	 * <pre>
	 * //#style inactiveStyle
	 * UiAccess.setAccessible( myScreen, myCommand, false );
	 * </pre>
	 * 
	 * @param screen the screen that contains the command
	 * @param command the item that should be made accessible 
	 * @param isAccessible true when the item should be accessible/selectable
	 * @param style the new style for the command, is ignored when null
	 */
	public static void setAccessible( Screen screen, Command command, boolean isAccessible, Style style ) {
		setAccessible( screen.getCommandItem(command), isAccessible, style );

	}
	//#endif
	
	//#if polish.midp
	/**
	 * Sets an image for the specified ticker.
	 * This method is ignored when the J2ME Polish UI is not activated.
	 * 
	 * @param ticker the ticker item which will the image be set 
	 * @param image that image that will be set to the ticker
	 */
	public static void setTickerImage( javax.microedition.lcdui.Ticker ticker, Image image ) {
		// ignore
	}
	//#endif
	
	//#if polish.usePolishGui
	/**
	 * Sets an image for the specified ticker.
	 * This method is ignored when the J2ME Polish UI is not activated.
	 * 
	 * @param ticker the ticker item which will the image be set 
	 * @param image that image that will be set to the ticker
	 */
	public static void setTickerImage( Ticker ticker, Image image ) {
		ticker.setImage(image);
	}
	//#endif
	
	//#if polish.usePolishGui
	/**
	 * Sets an image for the specified ticker.
	 * This method is ignored when the J2ME Polish UI is not activated.
	 * 
   * @param ticker the ticker item which will the image be set 
   * @param image that image that will be set to the ticker
	 */
	public static void setAccessible( Ticker ticker, Image image ) {
		ticker.setImage(image);
	}
	//#endif

	//#if polish.usePolishGui
	/**
	 * Attaches data to the specified screen.
	 * This mechanism can be used to add business logic to screens.
	 * 
	 * @param screen the screen in which the data should be stored
	 * @param data the screen specific data
	 * @see #getData(Screen)
	 */
	public static void setData(Screen screen, Object data) {
		screen.setScreenData( data );
	}
	//#endif

	//#if polish.usePolishGui
	/**
	 * Retrieves screen specific data.
	 * This mechanism can be used to add business logic to screens.
	 * 
	 * @param screen the screen in which data has been previously stored using UiAccess.setData()
	 * @return any screen specific data or null when no data has been attached before
	 * @see #setData(Screen, Object)
	 */
	public static Object getData(Screen screen) {
		return screen.getScreenData();
	}
	//#endif

	//#if polish.midp
	/**
	 * Attaches data to the specified screen.
	 * This mechanism can be used to add business logic to screens.
	 * 
	 * @param screen the screen in which the data should be stored
	 * @param data the screen specific data
	 * @see #getData(Screen)
	 */
	public static void setData( javax.microedition.lcdui.Screen screen, Object data) {
		if (attributes == null) {
			attributes = new HashMap();
		}
		attributes.put(screen, data);
	}
	//#endif

	//#if polish.midp
	/**
	 * Retrieves screen specific data.
	 * This mechanism can be used to add business logic to screens.
	 * 
	 * @param screen the screen in which data has been previously stored using UiAccess.setData()
	 * @return any screen specific data or null when no data has been attached before
	 * @see #setData(Screen, Object)
	 */
	public static Object getData(javax.microedition.lcdui.Screen screen) {
		if (attributes == null) {
			return null;
		}
		return attributes.get( screen );
	}
	//#endif

	//#if polish.midp
	/**
	 * Changes the shown label of the specified command.
	 * Note that command.getLabel() will afterwards retrieve the same string as before, 
	 * only the shown label will be changed. You cannot change the labels of the
	 * commands that are shown on the left or right side of the menu, unless the extended menubar is activated 
	 * (polish.MenuBar.useExtendedMenuBar=true).
	 * This call is ignored when J2ME Polish does not render the menu.
	 *
	 * @param screen the screen that contains the command
	 * @param command the command
	 * @param label the new label that should be shown
	 */
	public static void setCommandLabel( javax.microedition.lcdui.Screen screen, Command command, String label) {
		//ignore
	}
	//#endif
	
	//#if polish.usePolishGui
	/**
	 * Changes the shown label of the specified command.
	 * Note that command.getLabel() will afterwards retrieve the same string as before, 
	 * only the shown label will be changed. You cannot change the labels of the
	 * commands that are shown on the left or right side of the menu, unless the extended menubar is activated 
	 * (polish.MenuBar.useExtendedMenuBar=true).
	 * This call is ignored when J2ME Polish does not render the menu.
	 *
	 * @param screen the screen that contains the command
	 * @param command the command
	 * @param label the new label that should be shown
	 */
	public static void setCommandLabel( Screen screen, Command command, String label) {
		CommandItem item = screen.getCommandItem(command);
		if (item != null) {
			item.setText(label);
		}
	}
	//#endif

}

⌨️ 快捷键说明

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