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

📄 menuelementbase.java

📁 国外的j2me播放器软件
💻 JAVA
字号:
package no.auc.one.portableplayer.userinterface;

import javax.microedition.lcdui.Graphics;

/**
 * Base class for all kind of menu element.
 */
public abstract class MenuElementBase {
	protected String name = "";
    protected MenuEventListener currentEventListener = null;
    
    public MenuElementBase(String n) {
        name = n;
    }

    public MenuElementBase(String name, MenuEventListener listener) {
        this.name = name;
        currentEventListener = listener;
    }

	public void rename(String newName) {
		this.name = newName;
	}
    
	public String toString() {
		return name;
	}
    
    public final MenuEventListener getEventListener() {
        return currentEventListener;
    }

    public final void setEventListener(MenuEventListener mel) {
        currentEventListener = mel;
    }

    /**
     * Paints this menu element. This implementation is basic and only 
     * draws the name of it, whatever that is.
     */
    public void paint(Graphics g) {
        // System.out.println("Painting " + name + "(" + g.getClipX() + ", " + g.getClipY() + ")");
        
        g.drawString(
            name,
            g.getClipX(),
            g.getClipY(),
            Graphics.TOP | Graphics.LEFT);
    }
    
    public abstract void invokeAction();

    /**
     * Before current container is changed due to navigate left action.
     *
     * Logic used for left navigation:
     *  1) Current child element's prepareNavigateLeft is called.
     *  2) If true then, if parent is not null, parent's prepareNavigateLeft 
     *     is called.
     *  3) If also true then the current container's parent is set as the new 
     *     current container of the menu.
     *
     * @return True if it is ok to change the current container. False 
     *         otherwise.
     */
    public boolean prepareNavigateLeft() {
        return true;
    }
    
    /**
     * User navigates left.
     */
    public abstract void navigateLeft();

    /**
     * Before current container is changed due to navigate right action.
     *
     * Logic used for right navigation:
     *  1) If current child element is a container then it's 
     *     prepareNavigateRight is called.
     *  2) If true then it is set as the new current container.
     *  3) If current child element is a normal menu element then it's 
     *     navigateRight method is called.
     * 
     * @return True if it is ok to change the current container. False 
     *         otherwise.
     */
    public boolean prepareNavigateRight() {
        return true;
    }
    
    /**
     * User navigates right.
     */
    public abstract void navigateRight();

    public abstract void navigateUp();

    public abstract void navigateDown();
}

⌨️ 快捷键说明

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