技术中心

这里象征着我们的态度和能力

>用j2me提供的低级UI:CanvasImage和Graphics对象来绘制九宫格
作者:中国IT实验室    来源:中国IT实验室    发布时间:2012-01-09      浏览次数:5581
分享到:
欢迎进入Java社区论坛,与200万技术人员互动交流 >>进入
    2.九宫格布局为主题区和底部菜单区
    3.将一张240*320的图片设置为背景图
    4.根据屏幕宽高计算出各图标的位置,然后绘制各图标。
    具体效果,如图所示:
    核心代码如下:
    public static final String[] filenames = { "/01.png", "/02.png", "/03.png",
    "/04.png", "/05.png", "/06.png" };
    public static final String[] labels = { "公文推送", "通知公告", "日程安排", "通讯录查询",
    "会议室查询", "手机邮箱" };
    public Image[] icons = new Image[9];
    public void paint(Graphics g) {
    int cw = this.getWidth();
    int ch = this.getHeight();
    try {
    // paintHead(g);
    this.setFullScreenMode(true);
    Image img = Image.createImage("/sliderbgn.JPG");
    // g.drawImage(img,0, 0, Graphics.TOP|Graphics.LEFT);
    g.drawImage(img, 0, 0, Graphics.TOP
    | Graphics.LEFT);
    for (int i = 0; i < filenames.length; i++) {
    try {
    icons[i] = Image.createImage(filenames[i]);
    } catch (IOException ex) {
    }
    }
    int old_color = g.getColor();
    g.setColor(0xffffff);
    int startY=ch/4;
    for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 3; j++) {
    g.drawImage(icons[i * 3 + j], j * cw / 3 + 10, startY+i * ch*3 / 10,
    Graphics.TOP | Graphics.LEFT);
    g.drawString(labels[i * 3 + j], j * cw / 3 + 30, startY+i * ch*3 / 10
    + icons[i].getHeight(),
    Graphics.HCENTER | Graphics.TOP);
    }
    }
    g.setColor(old_color);
    paintBottom(g);
    } catch (Exception ex) {
    System.out.println(ex.toString());
    }
    }
4000-880-989
(24小时热线)
联系客服
微信公众号

官方公众号

小程序

©2008-2022 CORPORATION ALL Rights Reserved. 香港精准正版资料版权所有 滇ICP备09003328号-1 滇公网安备 53011102000818号 增值电信业务经营许可证号:滇B2-20110045
昆明那家网络公司好,新媒体运营,网站优化,网络推广,网站建设,网页设计,网站设计,网站推广,云南网站公司,昆明新媒体公司,云南网红主播,昆明SEO公司,昆明网站建设,昆明网络推广,昆明网站优化,昆明网站推广,红河网站建设,大理网络公司,曲靖网络公司,丽江网站设计,昭通网络公司,保山大数据服务,智慧高速建设,智慧校园服务,云南IDC服务商,网络安全测评,等保测评,网站关键词排名优化服务,服务客户尽超2000余家,一切尽在香港精准正版资料,服务电话:13888956730