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

TextArea组件的使用说明代码如下:


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
		
	}

}



TabbedPane组件的使用说明代码如下:

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
		
	}

}




文中需要的资源文件可在上篇博客中下载

你可能感兴趣的:(sun)