Lwuit中关于TextArea、TabbedPane组件的使用说明

[color=green]TextArea组件的使用说明[/color]代码如下:


package com.mopietek;

import java.io.IOException;

import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.TextArea;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.plaf.UIManager;
import com.sun.lwuit.util.Resources;

public class TextAreaLwuit extends MIDlet implements ActionListener{

protected void destroyApp(boolean unconditional)
throws MIDletStateChangeException {
// TODO Auto-generated method stub

}

protected void pauseApp() {
// TODO Auto-generated method stub

}

protected void startApp() throws MIDletStateChangeException {
// TODO Auto-generated method stub
Display.init(this);
try {
Resources res = Resources.open("/javaTheme.res");
UIManager.getInstance().setThemeProps(res.getTheme("javaTheme"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Form form = new Form("Test TextAreaLwuit");
form.setLayout(new BorderLayout());
TextArea textArea = new TextArea(5,20,TextArea.NUMERIC);
//设置TextArea是否可编辑,true为可编辑,false为不可编辑
textArea.setEditable(true);
form.addComponent(BorderLayout.NORTH,textArea);
form.show();




}

public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub

}

}



[color=green]TabbedPane组件的使用说明[/color]代码如下:

package com.mopietek;

import java.io.IOException;

import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.Label;
import com.sun.lwuit.TabbedPane;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.plaf.UIManager;
import com.sun.lwuit.util.Resources;

public class TabbedPaneLwuit extends MIDlet implements ActionListener{

protected void destroyApp(boolean unconditional)
throws MIDletStateChangeException {
// TODO Auto-generated method stub

}

protected void pauseApp() {
// TODO Auto-generated method stub

}

protected void startApp() throws MIDletStateChangeException {

Display.init(this);
try {
Resources res = Resources.open("/javaTheme.res");
UIManager.getInstance().setThemeProps(res.getTheme("javaTheme"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Form form = new Form("Test CheckBox");
form.setLayout(new BorderLayout());
TabbedPane tabbedPane = new TabbedPane(TabbedPane.TOP);
tabbedPane.addTab("Tab1", new Label("I am a TabbedPane!"));
tabbedPane.addTab("Tab2", new Label("Tab number 2"));
form.addComponent(BorderLayout.NORTH,tabbedPane);
form.show();
}

public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub

}

}



[color=red]文中需要的资源文件可在上篇博客中下载[/color]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值