首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> Java 程式設計 >> J2ME

Java ME 開發:低級界面繪圖之選單(一)

     編輯:J2ME

問題描述

手機程式中選單用途極廣,Java ME 中如何繪製選單?下面分享實現的選單功能,效果如圖所示:

選單效果示意圖

代碼清單

Color.java(參考 kf156《J2ME canvas 多級選單的實現》)

package com.token.view.components;

public class Color {
    public static int strong = 0xFF8C00;
    public static int warning1 = 0xFF4500;
    public static int warning2 = 0xFF0000;
    public static int error = 0xFF0000;
    public static int background = 0xF0FAE6;
    public static int menuFrame = 0xB8E58A;
    public static int label = 0xF0F8FF;
    public static int text = 0x314F12;
    public static int selectText = 0xFFFFFF;
    public static int selectBg = 0x548720;
    public static int cmdBarTop = 0x9FDB63;
    public static int cmdBarBottom = 0x81D130;
    public static int menuBg = 0xE0F5CB;
    public static int cmdSelectTop = 0x7DAB4F;
    public static int cmdSelectBottom = 0x5B9422;
    public static int linkClick = 0xFF0000;
    public static int frame = 0x458B00;
    public static int frameBg = 0x556B2F;
    public static final int GREY = 0xBBBBBB;
    public static final int BLACK = 0x0;
    public static final int WHITE = 0xFFFFFF;
    public static final int TRANSLUCENCY_WRITE = 0x55FFFFFF;
    public static final int TRANSLUCENCY_BLACK = 0x55000000;
    public static final byte STYLE_RED = 0;
    public static final byte STYLE_ORANGE = 1;
    public static final byte STYLE_YELLOW = 2;
    public static final byte STYLE_GREEN = 3;
    public static final byte STYLE_LIME = 4;
    public static final byte STYLE_CYAN = 5;
    public static final byte STYLE_AQUA = 6;
    public static final byte STYLE_SKY_BLUE = 7;
    public static final byte STYLE_BLUE = 8;
    public static final byte STYLE_PURPLE = 9;
    public static final byte STYLE_FUCHSIA = 10;
    public static final byte STYLE_MAGENTA = 11;
    public static final byte STYLE_BLACK = 12;
    public static int colorName = STYLE_GREEN;

    // 以下省略各風格顏色配置方法(redColor, orangeColor, ... blackColor)與切換邏輯
    // 完整代碼見原文
}

完整顏色風格切換代碼較長,此處僅列出核心常數與結構,詳細實現請參考原文。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved