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

📄 component.java

📁 j2me编写的一个在线游戏
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* ------------------------------------------------------------------------- *          Copyright 2004-2005 Nokia Corporation  All rights reserved.          Nokia Mobile Phones          Restricted Rights: Use, duplication, or disclosure by the          U.S. Government is subject to restrictions as set forth in          subparagraph (c)(1)(ii) of DFARS 252.227-7013, or in FAR          52.227-19, or in FAR 52.227-14 Alt. III, as applicable.          This software is proprietary to and embodies the          confidential technology of Nokia Possession, use, or copying          of this software and media is authorized only pursuant to a          valid written license from Nokia or an authorized          sublicensor.          Nokia  - Wireless Software Solutions * ------------------------------------------------------------------------- */package samples.ui;import java.util.Vector;import javax.microedition.lcdui.Font;import javax.microedition.lcdui.Graphics;import javax.microedition.lcdui.Image;/** * This class implements an abstract user interface class that * provides basic functions to control layout (position, width, * height), display (foreground/background color, font, shadows, * border, painting), and control (event dispatching and focus * control). */public abstract class Component {	    /** Standard shadow color. *///    public static final int SHADOW = 0x00606060;    /** Standard layout anchor settings. */    public static final int NW_ANCHOR = Graphics.TOP | Graphics.LEFT;    /** Color to use for background painting. If -1, background will      * not be drawn.      */    protected int background = -1;    /** Color to use for background painting when in focus.      *  If -1, defaults to <code>background</code>.     */    protected int focusBackground = -1;        /** Color to use for foreground painting. */    protected int foreground;    /** Color to use for foreground painting when in focus. */    protected int focusForeground = -1;    /** Color to use for font painting. */    protected int fontColor;    /** Color to use for font painting when in focus. */    protected int focusFontColor = -1;    /** Color to use for shadow */    protected int shadowColor = 0x00606060;        /** X coordinate of component position. */    protected int x = -1;    /** Y coordinate of component position. */    protected int y = -1;    /** Width of component. */    protected int width = 0;    /** Height of component. */    protected int height = 0;    /** Font for painting text. */    protected CustomFont font;//    protected  Font cfont;        protected String test_font = "Font1";//"/7pt-proportional.png";//           /** Number of pixels that text is indented from the left edge of     *  the widget, when it is rendered.     */    protected int textOffsetX = 3;    protected int textOffsetY = 2;    /**     * Array of images for background painting. Index 1 is used when     * the object has focus, and index 0 is used when the object does     * not have focus. */    private Image[] imgList;    private int[] colorList;    /** Vector of registered event listeners. */    protected Vector listeners;    /** Boolean indicating whether to draw borders or not. */    protected boolean drawBorders;    /** Boolean indicating whether to draw shadows or not. */    protected boolean drawShadows;    /** Boolean indicating whether the component can accept input focus. */    protected boolean focusable;    /** Boolean indicating whether the component has input focus or not. */    protected boolean focus;    /** The View object that controls the component. */    protected View view;    /**     * Create a new Component instance.     */    public Component() {        drawBorders = true;        listeners = new Vector();        //font = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN, Font.SIZE_SMALL);        font = new CustomFont(test_font);    	    }    /**     * Set the postion of this instance.     *     * @param x The X coordinate of the lower left corner of this instance.     * @param y The Y coordinate of the lower left corner of this instance.     */    public void setLocation(int x, int y) {        this.x = x;        this.y = y;        repaint();    }    /**     * Get the X coordinate of this instance.     *     * @return The X coordinate of the lower left corner of this instance.     */    public int getX() {        return x;    }    /**     * Get the Y coordinate of this instance.     *     * @return The Y coordinate of the lower left corner of this instance.     */    public int getY() {        return y;    }    /**     * Set whether the instance has input focus or not.     *     * @param focus Whether the instance has input focus.     */    public void setFocus(boolean focus) {        this.focus = focus;    }    /**     * Query whether the instance has input focus or not.     *     * @return Whether the instance has input focus.     */    public boolean hasFocus() {        return focus;    }    /**     * Set the dimensions of this instance.     *     * @param width The width of this instance.     * @param height The height of this instance.     */    public void setDimension(int width, int height) {        this.width = width;        this.height = height;        repaint();    }    /**     * Query whether the instance wants to be highlighted when it has focus.     *     * @return Whether the instance is highlighted.     */    public boolean wantsHighlight() {        return true;    }    /**     * Get the width of this instance.     *     * @return The width of this instance.     */    public int getWidth() {        return width;    }    /**     * Get the height of this instance.     *     * @return The height of this instance.     */    public int getHeight() {        return height;    }    /**     * Set the View object that controls this instance.     *     * @param view The View object that controls this instance.     */    public void setView(View view) {        this.view = view;    }    /**     * Get the View object that controls this instance.     *     * @return The View object that controls this instance.     */    public View getView() {        return view;    }    /**     * Set the font for this instance.     *     * @param font The font for this instance.     */    public void setFont(CustomFont font) {        this.font = font;    }    /**     * Get the font for this instance.     *     * @return The font for this instance.     */    public CustomFont getFont() {        return font;    }    /**     * Set the font color for this instance.     *     * @param fontColor The font color for this instance.     */    public void setFocusFontColor(int fontColor) {        this.focusFontColor = fontColor;    }    /**     * Get the font color for this instance.     *     * @return The font color for this instance.     */    public int getFocusFontColor() {        return focusFontColor;    }    /**     * Set the background color for this instance.     *     * @param background The background color for this instance.     */    public void setFocusBackground(int background) {        this.focusBackground = background;    }    /**     * Get the background color for this instance.     *     * @return The background color for this instance.     */    public int getFocusBackground() {        return focusBackground;    }    /**     * Set the foreground color for this instance.     *     * @param foreground The foreground color for this instance.     */    public void setFocusForeground(int foreground) {        this.focusForeground = foreground;    }    /**     * Get the foreground color for this instance     *     * @return The foreground color for this instance.     */    public int getFocusForeground() {        return focusForeground;    }    /**     * Set the font color for this instance.     *     * @param fontColor The font color for this instance.     */    public void setFontColor(int fontColor) {        this.fontColor = fontColor;    }    /**     * Get the font color for this instance.     *     * @return The font color for this instance.     */    public int getFontColor() {        return fontColor;    }            public int getShadowColor() {		return shadowColor;	}	public void setShadowColor(int shadowColor) {		this.shadowColor = shadowColor;	}	/**     * Set the background color for this instance.     *     * @param background The background color for this instance.     */    public void setBackground(int background) {        this.background = background;    }    /**     * Get the background color for this instance.     *     * @return The background color for this instance.     */    public int getBackground() {        return background;    }    /**     * Set the foreground color for this instance.     *     * @param foreground The foreground color for this instance.

⌨️ 快捷键说明

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