javaMe Tab

来源:技术人生 责任编辑:栏目编辑 发表时间:2013-07-02 01:01 点击:
 首先,先来说说“分页”,Win32控件中,有种控件叫做Tab,这个功能是把一个窗体分层,同时可以容纳更多控件(注:这里的分页并不是B/S的网络数据库中的分页)。

  在J2ME中实现Tab,可谓是件好事,包含Tab控件的Class可以作为主类,从而根据需求关联更多的应用。然后,使用Tab效果最好的是触摸屏手机...........

  LWUIT里的Text控件,跟原来的Text控件差不多,很多人都疑惑:Text控件输入汉字时,到底是用高级的输入框,还是在当前界面输入........答案是调用高级输入框!

  OK,废话少说,直接来代码,这里的代码也是修改自Sample例子:

   1. /*
   2.  * Copyright ?2008 Sun Microsystems, Inc. All rights reserved.
   3.  * Use is subject to license terms.
   4.  *
   5.  */
   6. package com.sun.lwuit.uidemo;
   7.
   8. import com.sun.lwuit.Button;
   9. import com.sun.lwuit.ButtonGroup;
  10. import com.sun.lwuit.Command;
  11. import com.sun.lwuit.Container;
  12. import com.sun.lwuit.Dialog;
  13. import com.sun.lwuit.Form;
  14. import com.sun.lwuit.Label;
  15. import com.sun.lwuit.RadioButton;
  16. import com.sun.lwuit.TabbedPane;
  17. import com.sun.lwuit.TextArea;
  18. import com.sun.lwuit.TextField;
  19. import com.sun.lwuit.events.ActionEvent;
  20. import com.sun.lwuit.events.ActionListener;
  21. import com.sun.lwuit.layouts.BorderLayout;
  22. import com.sun.lwuit.layouts.BoxLayout;
  23.
  24. /**
  25.  * 本例演示如何使用Tabbed、Text控件
  26.  */
  27. public class TabbedPaneDemo implements ActionListener {
  28.     public Form form = new Form("TabbedPaneDemo");
  29.     private  Command backCommand = new Command("Back", 1);
  30.     final TextArea title ;
  31.     final TextArea body;
  32.     TabbedPane tp = null;
  33.
  34.     TabbedPaneDemo() {
  35.         form.setLayout(new BorderLayout());
  36.         form.setScrollable(false);
  37.         form.addCommand(backCommand);
  38.         form.setCommandListener(this);
  39.         tp = new TabbedPane();
  40.
  41.         //addTab可以为页面添加控件,也可以是Container(相当于容器的控件)
  42.         tp.addTab("Tab 1", new Label("Welcome to TabbedPane demo!"));
  43.
  44.         //---------------------第二页的内容------------------------------------
  45.         //Container就是一个控件,只不过相当于容器,建议每页有自己的事件处理
  46.         Container radioButtonsPanel = new Container(new BoxLayout(BoxLayout.Y_AXIS));
  47.
  48.         RadioButton topRB = new RadioButton("Top");
  49.         RadioButton LeftRB = new RadioButton("Left");
  50.         RadioButton BottomRB = new RadioButton("Bottom");
  51.         RadioButton RightRB = new RadioButton("Right");
  52.
  53.         RadioListener rbListener = new RadioListener();//自定义接收事件的类
  54.         topRB.addActionListener(rbListener);
  55.         LeftRB.addActionListener(rbListener);
  56.         BottomRB.addActionListener(rbListener);
  57.         RightRB.addActionListener(rbListener);
  58.
  59.         ButtonGroup group1 = new ButtonGroup();
  60.         group1.add(topRB);
  61.         group1.add(LeftRB);
  62.         group1.add(BottomRB);
  63.         group1.add(RightRB);

    相关新闻>>

      发表评论
      请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
      用户名: 验证码:点击我更换图片
      最新评论 更多>>

      推荐热点

      • Java编程语言的八大优点
      • JVM对象生命周期详细介绍
      • Java平台上的CRM系统
      • Java 算数测试小程序
      • Command(命令模式)
      • Java 一个简单的画图程序
      • Java环境 使用Resin在NT环境下配置JSP环境
      • Java 日历的小程序
      • Java 统计代码的小工具
      网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
      Copyright © 2008-2015 计算机技术学习交流网. 版权所有

      豫ICP备11007008号-1