Ticker object can be associated with a subclass of Screen objects. Ticker is an object in the form of walking or writing a line of text that can discrolling constantly on display. Direction and speed of the Ticker can not be set manually, because it has been governed by the system and ongoing Ticker can not be stopped by the application. The following is a sample program Ticker.
1 import javax.microedition.midlet.*;
2 import javax.microedition.lcdui.*;
3
4 public class TickerDemo extends MIDlet implements CommandListener
5 {
6 private Form form;
7 private Ticker ticker;
8 private Display display;
9 private Command cmdKeluar;
10
11 public TickerDemo () {
12 }
13
14 public void startApp() {
15 form = new Form("Latihan Membuat Ticker");
16 ticker = new Ticker("Lab Sist Komp Lanjut");
17 form.setTicker(ticker);
18 display=Display.getDisplay(this);
19 display.setCurrent(form);
20 cmdKeluar = new Command ("Keluar", Command.EXIT, 0);
21 form.addCommand(cmdKeluar);
22 form.setCommandListener(this);
23 }
24
25 public void pauseApp() {
26 }
27
28 public void destroyApp(boolean unconditional) {
29 notifyDestroyed();
30 }
31
32 public void commandAction(Command c, Displayable d) {
33 if (c == cmdKeluar) {
34 destroyApp(true);
35 }
36 }
37 }
Output :
1 import javax.microedition.midlet.*;
2 import javax.microedition.lcdui.*;
3
4 public class TickerDemo extends MIDlet implements CommandListener
5 {
6 private Form form;
7 private Ticker ticker;
8 private Display display;
9 private Command cmdKeluar;
10
11 public TickerDemo () {
12 }
13
14 public void startApp() {
15 form = new Form("Latihan Membuat Ticker");
16 ticker = new Ticker("Lab Sist Komp Lanjut");
17 form.setTicker(ticker);
18 display=Display.getDisplay(this);
19 display.setCurrent(form);
20 cmdKeluar = new Command ("Keluar", Command.EXIT, 0);
21 form.addCommand(cmdKeluar);
22 form.setCommandListener(this);
23 }
24
25 public void pauseApp() {
26 }
27
28 public void destroyApp(boolean unconditional) {
29 notifyDestroyed();
30 }
31
32 public void commandAction(Command c, Displayable d) {
33 if (c == cmdKeluar) {
34 destroyApp(true);
35 }
36 }
37 }
Output :
0 komentar:
Post a Comment
Silahkan berkomentar, namun tetap jaga kesopanan dengan tidak melakukan komentar spam, dan tuliskan nama jelas.