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

📄 uiaccess.java

📁 j2me polish学习的经典代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
//#condition polish.midp || polish.usePolishGui/* * Created on 31-Jan-2006 at 00:04:45. *  * Copyright (c) 2005 Robert Virkus / Enough Software * * This file is part of J2ME Polish. * * J2ME Polish is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. *  * J2ME Polish is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. *  * You should have received a copy of the GNU General Public License * along with J2ME Polish; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *  * Commercial licenses are also available, please * refer to the accompanying LICENSE.txt or visit * http://www.j2mepolish.org for details. */package de.enough.polish.ui;import javax.microedition.lcdui.Command;import javax.microedition.lcdui.Display;import javax.microedition.lcdui.Displayable;/** * <p>Allows to access J2ME Polish specific features in a standard compliant way.</p> * <p>When a ScreenStateListener is registered with a screen, it will get notified when *    the screen changes its focus or another internal state (like changing a tab in the TabbedForm). * </p> * * <p>Copyright (c) 2005, 2006 Enough Software</p> * <pre> * history *        31-Jan-2006 - rob creation * </pre> * @author Robert Virkus, j2mepolish@enough.de */public final class UiAccess {		/**	 * A constant for setting the input mode of an TextField to lowercase.	 * @see #setInputMode(javax.microedition.lcdui.TextField, int)	 */	public static final int MODE_LOWERCASE = 0;	/**	 * A constant for setting the input mode of an TextField to uppercase for the first character, followed by lowercase characters.	 * @see #setInputMode(javax.microedition.lcdui.TextField, int)	 */	public static final int MODE_FIRST_UPPERCASE = 1; // only the first character should be written in uppercase	/**	 * A constant for setting the input mode of an TextField to uppercase.	 * @see #setInputMode(javax.microedition.lcdui.TextField, int)	 */	public static final int MODE_UPPERCASE = 2;	/**	 * A constant for setting the input mode of an TextField to numbers.	 * @see #setInputMode(javax.microedition.lcdui.TextField, int)	 */	public static final int MODE_NUMBERS = 3;	/**	 * A constant for setting the input mode of an TextField to it't native input - that's useful for using T9 and similar input helpers.	 * @see #setInputMode(javax.microedition.lcdui.TextField, int)	 */	public static final int MODE_NATIVE = 4;	/**	 * No instantiation is allowd.	 */	private UiAccess() {		super();	}		//#if polish.usePolishGui	/**	 * Registers a ScreenStateListener to any J2ME Polish screen.	 * 	 * @param screen the screen	 * @param listener the listener	 */	public static void setScreenStateListener( javax.microedition.lcdui.Screen screen, ScreenStateListener listener ) {		// ignore, just for being able to use the ScreenStateListener along with a normal screen.	}	//#endif	//#if polish.usePolishGui	/**	 * Registers a ScreenStateListener to any J2ME Polish screen.	 * 	 * @param screen the screen	 * @param listener the listener	 */	public static void setScreenStateListener( Screen screen, ScreenStateListener listener ) {		screen.setScreenStateListener( listener );	}	//#endif		/**	 * Retrieves the focused index of the specified screen	 * 	 * @param screen the screen	 * @return the focused index, -1 when it is not known	 */	public static int getFocusedIndex( javax.microedition.lcdui.Screen screen ) {		return -1;	}	//#if polish.usePolishGui	/**	 * Retrieves the focused index of the specified screen	 * 	 * @param screen the screen	 * @return the focused index, -1 when it is not known	 */	public static int getFocusedIndex( Screen screen ) {		if (screen.container != null) {			return screen.container.getFocusedIndex();		}		return -1;	}	//#endif	/**	 * Retrieves the focused index of the specified screen	 * 	 * @param screen the screen	 * @return the focused item, null when it is not known	 */	public static javax.microedition.lcdui.Item getFocusedItem( javax.microedition.lcdui.Screen screen ) {		return null;	}	//#if polish.usePolishGui	/**	 * Retrieves the focused index of the specified screen	 * 	 * @param screen the screen	 * @return the focused item, null when it is not known	 */	public static Item getFocusedItem( Screen screen ) {		return screen.getCurrentItem();	}	//#endif	//#if polish.midp2	/**	 * Sets the title of the screen using an Item.	 * <b>important</b>: you cannot call screen.setTitle(String) afterwards anymore!	 * 	 * @param screen the screen for which the title should be replaced 	 * @param title the element responsible for painting the title.	 */	public static void setTitle( javax.microedition.lcdui.Screen screen, javax.microedition.lcdui.Item title ) {		// this is ignored.	}	//#endif	//#if polish.usePolishGui	/**	 * Sets the title of the screen using an Item.	 * <b>important</b>: you cannot call screen.setTitle(String) afterwards anymore!	 * 	 * @param screen the screen for which the title should be replaced 	 * @param title the element responsible for painting the title.	 */	public static void setTitle( Screen screen, Item title ) {		screen.setTitle( title );	}	//#endif	//#if polish.usePolishGui	/**	 * Sets the title of the screen using an Item.	 * <b>important</b>: you cannot call screen.setTitle(String) afterwards anymore!	 * This method is meant to be used in conjunction with the //#style preprocessing directive.	 * 	 * @param screen the screen for which the title should be replaced 	 * @param title the element responsible for painting the title.	 * @param style the style for the title	 */	public static void setTitle( Screen screen, Item title, Style style ) {		if (style != null) {			title.setStyle(style);		}		screen.setTitle( title );	}	//#endif	//#if polish.usePolishGui	/**	 * Sets the title of the screen using an Item.	 * <b>important</b>: you cannot call screen.setTitle(String) afterwards anymore!	 * 	 * @param screen the screen for which the title should be replaced 	 * @param title the element responsible for painting the title.	 */	public static void setTitle( javax.microedition.lcdui.Screen screen, Item title ) {		// ignore	}	//#endif	//#if polish.usePolishGui	/**	 * Sets the title of the screen using an Item.	 * <b>important</b>: you cannot call screen.setTitle(String) afterwards anymore!	 * This method is meant to be used in conjunction with the //#style preprocessing directive.	 * 	 * @param screen the screen for which the title should be replaced 	 * @param title the element responsible for painting the title.	 * @param style the style for the title	 */	public static void setTitle( javax.microedition.lcdui.Screen screen, Item title, Style style ) {		// ignore	}	//#endif	/**	 * Adds a command to a list item.	 * Warning: this method won't add any commands when the J2ME Polish GUI is not activated.	 * 	 * @param list the list	 * @param index the index of the item	 * @param command the item command	 */	public static void addItemCommand( javax.microedition.lcdui.List list, int index, Command command ) {		// ignore on real lists	}		//#if polish.usePolishGui	/**	 * Adds a command to a list item.	 * Warning: this method won't add any commands when the J2ME Polish GUI is not activated.	 * 	 * @param list the list	 * @param index the index of the item	 * @param command the item command	 */	public static void addItemCommand( List list, int index, Command command ) {		Item item = list.getItem(index);		item.addCommand(command);	}	//#endif		//#if polish.usePolishGui	/**	 * Sets the parent for the given child item.	 * 	 * @param child the child	 * @param parent the parent	 */	public static void setParent( Item child, Item parent ) {		child.parent = parent;	}	//#endif		//#if polish.usePolishGui	/**	 * Sets the parent for the given child item.	 * 	 * @param child the child	 * @param parent the parent	 */	public static void setParent( Item child, javax.microedition.lcdui.Item parent ) {		// ignore	}	//#endif	/**	 * Sets the parent for the given child item.	 * 	 * @param child the child	 * @param parent the parent	 */	public static void setParent( javax.microedition.lcdui.Item child, javax.microedition.lcdui.Item parent ) {		// ignore	}		/**	 * Retrieves the internal x position of the given item.	 * When it is equal -9999 this item's internal position is not known.	 * The internal position is useful for items that have a large content which	 * needs to be scrolled, e.g. containers.  	 * 	 * @param item the item	 * @return the internal x position of this item's currently selected content, -9999 when it is unknown.	 */	public static int getInternalX( javax.microedition.lcdui.Item item ) {		return -9999;	}	/**	 * Retrieves the internal y position of the given item.	 * The internal position is useful for items that have a large content which	 * needs to be scrolled, e.g. containers.  	 * 	 * @param item the item	 * @return the internal y position of this item's currently selected content.	 * @see #getInternalX(javax.microedition.lcdui.Item)	 */	public static int getInternalY( javax.microedition.lcdui.Item item ) {		return -1;	}		/**	 * Retrieves the internal width of the given item.	 * The internal position is useful for items that have a large content which	 * needs to be scrolled, e.g. containers.  	 * 	 * @param item the item	 * @return the internal width of this item's currently selected content.	 * @see #getInternalX(javax.microedition.lcdui.Item)	 */	public static int getInternalWidth( javax.microedition.lcdui.Item item ) {		return -1;	}	/**	 * Retrieves the internal height of the given item.	 * The internal position is useful for items that have a large content which	 * needs to be scrolled, e.g. containers.  	 * 	 * @param item the item	 * @return the internal height of this item's currently selected content.	 * @see #getInternalX(javax.microedition.lcdui.Item)	 */	public static int getInternalHeight( javax.microedition.lcdui.Item item ) {		return -1;	}		//#if polish.usePolishGui	/**	 * Retrieves the internal x position of the given item.	 * When it is equal -9999 this item's internal position is not known.	 * The internal position is useful for items that have a large content which	 * needs to be scrolled, e.g. containers.  	 * 	 * @param item the item	 * @return the internal x position of this item's currently selected content, -9999 when it is unknown.	 */	public static int getInternalX( Item item ) {		return item.internalX;	}	//#endif	//#if polish.usePolishGui	/**	 * Retrieves the internal y position of the given item.	 * The internal position is useful for items that have a large content which	 * needs to be scrolled, e.g. containers.  	 * 	 * @param item the item	 * @return the internal y position of this item's currently selected content.	 * @see #getInternalX(Item)	 */	public static int getInternalY( Item item ) {		return item.internalY;	}	//#endif		//#if polish.usePolishGui	/**	 * Retrieves the internal width of the given item.	 * The internal position is useful for items that have a large content which	 * needs to be scrolled, e.g. containers.  	 * 	 * @param item the item	 * @return the internal width of this item's currently selected content.	 * @see #getInternalX(Item)	 */	public static int getInternalWidth( Item item ) {		return item.internalWidth;	}	//#endif	//#if polish.usePolishGui	/**	 * Retrieves the internal height of the given item.	 * The internal position is useful for items that have a large content which	 * needs to be scrolled, e.g. containers.  	 * 	 * @param item the item	 * @return the internal height of this item's currently selected content.	 * @see #getInternalX(Item)	 */	public static int getInternalHeight( Item item ) {		return item.internalHeight;	}	//#endif		//#if polish.usePolishGui	public static Style focus( Item item, int direction, Style style ) {		return item.focus(style, direction);	}	//#endif		//#if polish.usePolishGui	public static void defocus( Item item, Style style ) {		item.defocus(style);	}	//#endif		/**

⌨️ 快捷键说明

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