13,100
社区成员
发帖
与我相关
我的任务
分享
1.package com.mopietek;
2.
3.import java.io.IOException;
4.
5.import javax.microedition.midlet.MIDlet;
6.import javax.microedition.midlet.MIDletStateChangeException;
7.
8.import com.sun.lwuit.Display;
9.import com.sun.lwuit.Form;
10.import com.sun.lwuit.TextArea;
11.import com.sun.lwuit.events.ActionEvent;
12.import com.sun.lwuit.events.ActionListener;
13.import com.sun.lwuit.layouts.BorderLayout;
14.import com.sun.lwuit.plaf.UIManager;
15.import com.sun.lwuit.util.Resources;
16.
17.public class TextAreaLwuit extends MIDlet implements ActionListener{
18.
19. protected void destroyApp(boolean unconditional)
20. throws MIDletStateChangeException {
21. // TODO Auto-generated method stub
22.
23. }
24.
25. protected void pauseApp() {
26. // TODO Auto-generated method stub
27.
28. }
29.
30. protected void startApp() throws MIDletStateChangeException {
31. // TODO Auto-generated method stub
32. Display.init(this);
33. try {
34. Resources res = Resources.open("/javaTheme.res");
35. UIManager.getInstance().setThemeProps(res.getTheme("javaTheme"));
36. } catch (IOException e) {
37. // TODO Auto-generated catch block
38. e.printStackTrace();
39. }
40.
41. Form form = new Form("Test TextAreaLwuit");
42. form.setLayout(new BorderLayout());
43. TextArea textArea = new TextArea(5,20,TextArea.NUMERIC);
44. //设置TextArea是否可编辑,true为可编辑,false为不可编辑
45. textArea.setEditable(true);
46. form.addComponent(BorderLayout.NORTH,textArea);
47. form.show();
48.
49.
50.
51.
52. }
53.
54. public void actionPerformed(ActionEvent arg0) {
55. // TODO Auto-generated method stub
56.
57. }
58.
59.}
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组件的使用说明代码如下:
Java代码
1.package com.mopietek;
2.
3.import java.io.IOException;
4.
5.import javax.microedition.midlet.MIDlet;
6.import javax.microedition.midlet.MIDletStateChangeException;
7.
8.import com.sun.lwuit.Display;
9.import com.sun.lwuit.Form;
10.import com.sun.lwuit.Label;
11.import com.sun.lwuit.TabbedPane;
12.import com.sun.lwuit.events.ActionEvent;
13.import com.sun.lwuit.events.ActionListener;
14.import com.sun.lwuit.layouts.BorderLayout;
15.import com.sun.lwuit.plaf.UIManager;
16.import com.sun.lwuit.util.Resources;
17.
18.public class TabbedPaneLwuit extends MIDlet implements ActionListener{
19.
20. protected void destroyApp(boolean unconditional)
21. throws MIDletStateChangeException {
22. // TODO Auto-generated method stub
23.
24. }
25.
26. protected void pauseApp() {
27. // TODO Auto-generated method stub
28.
29. }
30.
31. protected void startApp() throws MIDletStateChangeException {
32.
33. Display.init(this);
34. try {
35. Resources res = Resources.open("/javaTheme.res");
36. UIManager.getInstance().setThemeProps(res.getTheme("javaTheme"));
37. } catch (IOException e) {
38. // TODO Auto-generated catch block
39. e.printStackTrace();
40. }
41.
42. Form form = new Form("Test CheckBox");
43. form.setLayout(new BorderLayout());
44. TabbedPane tabbedPane = new TabbedPane(TabbedPane.TOP);
45. tabbedPane.addTab("Tab1", new Label("I am a TabbedPane!"));
46. tabbedPane.addTab("Tab2", new Label("Tab number 2"));
47. form.addComponent(BorderLayout.NORTH,tabbedPane);
48. form.show();
49. }
50.
51. public void actionPerformed(ActionEvent arg0) {
52. // TODO Auto-generated method stub
53.
54. }
55.
56.}