button.java

来自「J2ME上的一个播放器,可以更换皮肤.开源软件.」· Java 代码 · 共 67 行

JAVA
67
字号
package inline.ui.ce;

import inline.ui.*;
import java.util.*;
import javax.microedition.lcdui.*;

    public class Button extends CanvasElement 
    {
        private String caption;

        private int vctsel = 0;
        private int intsta = 0;
        private int intend = 0;
        

        public Button(HostCanvas prnt, int x, int y, int w, int h, String ccaption)
        {
            super(prnt, x,y,w,h);
            caption = ccaption;
        }
        
        protected final boolean drawFocus()
        {
            return true;
        }
        
        protected final boolean drawBorder()
        {
            return true;
        }
        
	public final boolean canFocus()
        {
            return true;
        }

        public void paintElement(Graphics g) 
        {
            synchronized (g) 
            {
		g.drawString(caption, 0, 0, 0);
            }
        }
        
        public void keyPressedElement(int keyCode)
        {
            boolean paint = false;
            
            if (keyCode == CENTER)
            {
		parent.selectPreview(this);
            }
        }

	protected int getContentWidthImpl()
	{
	    return getFont().stringWidth(caption); 
	}

	protected int getContentHeightImpl()
	{
	    return getFontHeight(); 
	}
	
    }

⌨️ 快捷键说明

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