หน้าแรก
 การบ้าน
  C/C++ new
  Java new
  Windows Phone
  แจ้งเรื่องที่ต้องการ
 บทความ
  .NET
  Android
  Blackberry
  C++Builder
  Delphi
  Java
  Mobile
  Open Source
  Pocket PC
  Visual Basic
  Web
  Windows Phone
  Others
 แบบเรียนฟรี
  ASP
  ASP.NET Webmatrix
  C++
  eVB
  J2ME
  Java
  PHP
 ซอร์สโค้ด
  Android
  ASP
  C++
  VC++
  CGI-Perl
  Delphi
  Java
  jQuery
  PHP
  Visual Basic
  .NET
 บริการจากเรา
  เปิดท้าย... ขายโค้ด
  Freeware
  อัตราค่าโฆษณา
  รายชื่อลูกค้า
  สถิติผู้เข้าเว็บ
 ดาว์นโหลด
 ค้นหาข้อมูล
 กระดานสนทนา
  .NET
  C/C++
  Delphi
  Java
  Palm/PocketPC
  Visual Basic
  Web
  อื่นๆ
 กระดานงาน
 ลิงค์เว็บ
 เกี่ยวกับผม
 อัตราค่าโฆษณา
Social Network

Facebook  Twitter  YouTube
 New Article
 Webboard
 Freelanceboard
Freeware
โปรแกรมเบอร์ดี (BerDee)
โปรแกรมเบอร์ดี (Android)
เกมส์เป่ายิ้งฉุบ
เกมส์เป่ายิ้งฉุบ(Android)
WebcamMonitor
WebcamMonitor(Windows)
scSendMail
scSendMail(Windows)
MSN Caption
MSN Caption(Windows)
  Freelance comment
  ติดต่อสอบถามมาได้ตลอดนะ...
2015-07-29 13:35:58
  ถ้าผมต้องการเว็บที่พัฒน...
2015-01-18 15:33:54
  ถ้าผมต้องการเว็บที่พัฒน...
2015-01-18 15:32:51
  ติดต่อสอบถามเข้ามาได้นะ...
2014-01-06 12:47:38
  ถ้ายังหาคนสอนไม่ได้ ก็ลอ...
2013-07-06 01:04:37
  สนใจส่งขอบเขตมาคุยราคาก...
2013-03-24 18:54:20
  ถ้ายังไม่มีคนรับงานติดต...
2012-12-16 19:18:14
  สนใจคะ ติดต่อ 0905076277...
2012-11-12 11:07:46
  รับทำโปรเจ็คนักศึกษาหรื...
2012-10-29 03:10:46
  sukit_te34@hotmail.com...
2012-10-29 03:09:36
  Webboard comment
  เขียนโปรแกรมภาษาจาวา
1.โ...

2023-09-12 11:40:28
  ต้องลอง debug ดูเองครับ
ไล่...

2023-06-08 18:03:06
  ร้านค้าแห่งหนึ่ง จะต้องน...
2021-09-21 08:47:08
  จงเขียนโปรแกรมดำเนินการ...
2021-05-07 15:06:11
  จงเขียนโปรแกรมสำหรับคำน...
2021-03-09 14:21:45
  ขอดู...
2021-01-04 23:56:45
  ขอโค้ดเพื่อทำการเรียนกา...
2020-12-09 23:02:09
  แล้ว ?...
2020-12-09 10:56:34
  จ้า...
2020-10-18 16:53:21
  พอดีผมเหลื่อแค่ตัดสต๊อก...
2020-05-31 21:49:43
  Homework comment
  เขียนโปรแกรมเพื่อรับค่า...
2022-02-24 10:45:17
  จากโค้ดนี้อะครับ พอดีลอง...
2021-03-22 01:22:39
  จากโค้ดนี้อะครับ พอดีลอง...
2021-03-22 01:22:39
  โจทย์การบ้าน c++ เขียนรูปแ...
2020-04-06 11:01:33
  แบบนี้ขอเป็น ภาษา php หน่อย...
2019-09-18 14:36:34
  ผมไม่อยากให้คุณได้คะแนน...
2019-04-27 01:29:07
  อาจารย์เขาบอกแนวข้อสอบม...
2019-04-27 00:44:29
  ขอสอบถามการเขียน c++ ครับ เ...
2018-04-02 12:19:21
  โค้ดตัวอย่างศึกษาให้เข้...
2017-11-26 14:50:05
  คำนวณค่าน้ำโดยรับค่ามิเ...
2017-11-20 23:15:26
  Article comment
  เท่าที่อ่าน error คือพื้นที่...
2022-03-23 13:56:48
  เรียน สอบถามปัญหา กับ อ.คร...
2022-01-24 17:39:49
  ต้องการ ให้เขียน โปรแกรม ...
2019-12-09 11:39:58
  รับเขียน arx จาก vc++ 2017 ล็อคโปร...
2019-09-19 09:48:09
  ทำการ register ไฟล์ที่ชื่อ mswinsck.oc...
2019-09-17 14:05:56
  ใน vb 6 ไม่มี component winsock เลยค่ะ ส...
2019-09-03 10:31:02
  รบกวนขอสอบถามหน่อยนะครั...
2019-03-04 05:31:04
  สามารถนำตัวหนังสือจากภา...
2018-12-25 08:54:32
  มีcode ของ VB ไหมค่ะ ถ้ามีรบกว...
2017-09-28 16:50:02
  น่าจะได้ครับ ไม่เคยลอง
...

2017-07-11 09:59:35
  9Mcode comment

Link Exchange

อัตราค่าโฆษณา
 
 J2ME (Java Micro Edition) Tutorial  

- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -

 J2ME (Java Micro Edition)
 
 

บทที่ 4 ภาคปฏิบัติ

 

บทที่ 4 ภาคปฏิบัติ

จัดเตรียมเครื่องมือ

สำหรับเครื่องมือ ที่จะเป็นเครื่องมือ หลังในหนังสือเล่มนี้คือ J2ME Wireless Toolkits(WTK) ซึ่งในขณะที่ผมเขียนบทความอยู่นี้ ได้มีการการออกตัว Version 2 ออกมาแล้ว ซึ่งรุ่นใหม่นี้ จะรองรับกับ MIDP 2.0 และความสามารถอื่นๆที่เพิ่มเข้ามา คุณสามารถทำการ Download โปรแกรมนี้ได้จาก http://java.sun.com/products/j2mewtoolkit/index.html สำหรับการติดตั้งและใช้งาน J2ME Wireless Toolkits(WTK) คุณสามารถกลับไปอ่านได้จาก ในบทที่ 3

หากคุณต้องการ โปรแกรมอื่นๆ ที่จะช่วยในการพัฒนา คุณสามารถอ่าน เพิ่มเติมได้จาก บทที่ 4 ครับ

เริ่มต้นสร้าง โปรแกรมใหม่

  • ในการเริ่มต้นสร้าง โปรแกรมใหม่ จะมีขั้นตอน และวิธีการเช่นเดียวกับ ในหัวข้อ การติดตั้งและใช้งาน J2ME Wireless Toolkits(WTK) ของบทที่ 3
  • กำหนด MIDlet Class Name ตามชื่อ ของไฟล์ตัวอย่าง เช่นไฟล์ตัวอย่าง ชื่อว่า HelloComman.java เราจะกำหนด MIDlet Class Name เป็น HelloCommand
  • ทำการแก้ไข ค่าของ MicroEdition-Profile เป็น MIDP-1.0 (เพราะต้องการ ใช้งานกับ MIDP-1.0 และทดสอบกับมือถือที่รองรับ เช่น Nokia 3650 และ 7650)
  • สร้างไฟล์ตัวอย่าง บันทึกไว้ในโฟล์ C:\WTK20\apps\HelloCommand\src
  • ทดสอบโปรแกรมโดยกดปุ่ม Run ของโปรแกรม J2ME Wireless Toolkits

ตัวอย่างที่ 1 Command Example

HelloCommand.java

Download Code Download Code
/*
* HelloCommand.java
*
* Created on 13 ??????? 2546, 16:38 ?.
*/

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

/**
* An example MIDlet with simple "Hello" text and an Exit command.
* Refer to the startApp, pauseApp, and destroyApp
* methods so see how each handles the requested transition.
*
* @author sup98
* @version
*/
public class HelloCommand extends MIDlet implements CommandListener {

private Command exitCommand; // The exit command
private Display display; // The display for this MIDlet

public HelloCommand() {
display = Display.getDisplay(this);
exitCommand = new Command("Exit", Command.SCREEN, 2);
}

/**
* Start up the Hello MIDlet by creating the TextBox and associating
* the exit command and listener.
*/

public void startApp() {
TextBox t = new TextBox("Hello MIDlet", "Test string", 256, 0);

t.addCommand(exitCommand);
t.setCommandListener(this);

display.setCurrent(t);
}

/**
* Pause is a no-op since there are no background activities or
* record stores that need to be closed.
*/

public void pauseApp() {
}

/**
* Destroy must cleanup everything not handled by the garbage collector.
* In this case there is nothing to cleanup.
*/

public void destroyApp(boolean unconditional) {
}

/*
* Respond to commands, including exit
* On the exit command, cleanup and notify that the MIDlet has been destroyed.
*/
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}

}

ผลการ Run

Hello MIDlet
รูปที่ 34 แสดงหน้าต่าง Emulator ที่ run MIDlet ที่เขียนขึ้น

อธิบาย: ส่วนของโค้ดจะเริ่มต้นจาก การสั่ง import ชุดคำสั่งที่จำเป็นในการทำงาน และมีการประกาศสร้าง class ซึ่งเป็น MIDlet ของเรานั้นเอง โดยทำการสืบทอดจาก MIDlet พร้อมทั้งมีการสั่ง implement CommandListener เพื่อให้สามารถรับ Event (เหตุการณ์) ของ ปุ่ม (Command) ได้

ต่อจากนั้น จะเป็นการประกาศตัวแปร สำหรับแสดงผล (display) และ ปุ่ม (HelloCommand.jad)

เมื่อเริ่มสร้าง โปรแกรม (อยู่ใน public HelloCommand() ) จะมีการสร้าง Object สำหรับแสดงผล (display) และ ปุ่ม (exitCommand)

เมื่อเริ่มต้น โปรแกรม (อยู่ใน public void startApp() ) จะมีการสร้าง Object ของ TextBox สำหรับกรอกข้อความ พร้อมทั้ง นำ exitCommand ไปไว้กับ TextBox โดยใช้คำสั่ง addCommand หลังจากนั้น ก็ใช้คำสั่ง setCommandListener เพื่อให้ exitCommand ส่งเหตุการณ์ (Event) การคลิก ได้

สุดท้าย ก็ทำการแสดง TextBox ออกที่หน้าจอภาพ

เมื่อมีผู้ใช้ทำการคลิกที่ปุ่ม จะมีการเรียกใช้งาน public void commandAction(Command c, Displayable s) โดยมีการตรวจสอบ ว่าเป็นการคลิกปุ่ม exitCommand หรือไม่ หากใช่แล้ว จะมีการเรียกคำสั่ง เพื่อจบโปรแกรม

หลักจาก คลิกที่ปุ่ม Build หรือ Run ของ โปรแกรม J2ME Wireless Tookits แล้ว เราจะได้ไฟล์ HelloCommand.jad ซึ่งอยู่ใน โฟล์เดอร์ ที่ชื่อ Bin ที่เราจะสามารถส่งเข้าไปยัง เครื่องมือถือ ที่เราได้ต้องการ และทดสอบการทำงานกับเครื่อง ได้ทันที


ตัวอย่างที่ 2 MultipleCommand

MultipleCommand.java

Download Code Download Code
/* * MultipleCommand.java * * Created on 13 ??????? 2546, 16:38 ?. */

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
* An example MIDlet with simple "Hello" text and an Exit command.
* Refer to the startApp, pauseApp, and destroyApp
* methods so see how each handles the requested transition.
*
* @author sup98
* @version
*/

public class MultipleCommand extends MIDlet implements CommandListener {

private Command exitCommand; // The exit command
private Command infoCommand, buyCommand;
private Display display; // The display for this MIDlet

public MultipleCommand() {
display = Display.getDisplay(this);
exitCommand = new Command("Exit", Command.SCREEN, 1);
infoCommand = new Command("Info", Command.SCREEN, 2);
buyCommand = new Command("buy", Command.SCREEN, 2);
}

/**
* Start up the Hello MIDlet by creating the TextBox and associating
* the exit command and listener.
*/

public void startApp() {
TextBox t = new TextBox("Hello MIDlet", "Test string",
256, 0);

t.addCommand(exitCommand);
t.addCommand(infoCommand);
t.addCommand(buyCommand);
t.setCommandListener(this);

display.setCurrent(t);
}

/**
* Pause is a no-op since there are no background activities or
* record stores that need to be closed.
*/

public void pauseApp() {
}

/**
* Destroy must cleanup everything not handled by the garbage collector.
* In this case there is nothing to cleanup.
*/

public void destroyApp(boolean unconditional) {
}

/*
* Respond to commands, including exit
* On the exit command, cleanup and notify that the MIDlet has been destroyed.
*/

public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}

}

ผลการ Run

MultipleCommand MIDlet
รูปที่ 35 แสดงหน้าต่าง Emulator ที่ run MIDlet ที่เขียนขึ้น

อธิบาย: โค้ดข้างต้น เป็นตัวอย่างในการเพิ่มปุ่ม (Command) เข้าไปยัง TextBox เพื่อให้เลือกเป็นเมนูต่างๆ


ตัวอย่างที่ 3 TextBox Demo

TextBoxDemo.java

Download Code Download Code
/* * TextBoxDemo.java * * Created on 13 ??????? 2546, 16:38 ?. */

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
* An example MIDlet with simple "Hello" text and an Exit command.
* Refer to the startApp, pauseApp, and destroyApp
* methods so see how each handles the requested transition.
*
* @author sup98
* @version
*/

public class TextBoxDemo extends MIDlet implements CommandListener {

private Command exitCommand, okCommand; // The exit command
private Display display; // The display for this MIDlet
private TextBox t;

public TextBoxDemo() {
display = Display.getDisplay(this);
t = new TextBox("Enter Phone Number","018116855",10,TextField.PHONENUMBER);

exitCommand = new Command("Exit", Command.EXIT, 2);
okCommand = new Command("OK", Command.OK,2);

}

/**
* Start up the Hello MIDlet by creating the TextBox and associating
* the exit command and listener.
*/

public void startApp() {

t.addCommand(exitCommand);
t.addCommand(okCommand);
t.setCommandListener(this);

display.setCurrent(t);
}

/**
* Pause is a no-op since there are no background activities or
* record stores that need to be closed.
*/

public void pauseApp() {
}

/**
* Destroy must cleanup everything not handled by the garbage collector.
* In this case there is nothing to cleanup.
*/

public void destroyApp(boolean unconditional) {
}

/*
* Respond to commands, including exit
* On the exit command, cleanup and notify that the MIDlet has been destroyed.
*/

public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}

}

ผลการ Run

TextBoxDemo MIDlet
รูปที่ 36 แสดงหน้าต่าง Emulator ที่ run MIDlet ที่เขียนขึ้น

อธิบาย: โค้ดข้างต้น เป็นตัวอย่างในการป้อนหมายเลขโทรศัพท์ เข้าไปยัง TextBox พร้อมปุ่ม OK และ Exit


ตัวอย่างที่ 4 List Demo

ListDemo.java

Download Code Download Code
/* * ListDemo.java * * Created on 13 ??????? 2546, 16:38 ?. */
      
        import javax.microedition.midlet.*;
        import javax.microedition.lcdui.*;
      /**
        * An example MIDlet with simple "Hello" text and an Exit command.
        * Refer to the startApp, pauseApp, and destroyApp
        * methods so see how each handles the requested transition.
        *
        * @author sup98
        * @version
        */
        public class ListDemo extends MIDlet implements CommandListener {
        
        private Command exitCommand, backCommand; 
        private Display display; // The display for this MIDlet
        private List menu, l1, l2, l3;
        
        public ListDemo() {
        display = Display.getDisplay(this);
        exitCommand = new Command("Exit", Command.EXIT, 1);
        backCommand = new Command("Back", Command.BACK,2);

        }
        
        /**
        * Start up the Hello MIDlet by creating the TextBox and associating
        * the exit command and listener.
        */
        public void startApp() {
	  menu = new List("List Types",Choice.IMPLICIT);
	  menu.append("Implicit",null);
	  menu.append("Multiple",null);
	  menu.append("Exclusive",null);
	  menu.addCommand(exitCommand);
        menu.setCommandListener(this);

	  l1 = new List("Language",Choice.IMPLICIT);
	  l1.append("Java",null);
	  l1.append("VB",null);
	  l1.append("C#",null);
	  l1.append("C++",null);
	  l1.addCommand(backCommand);
	  l1.setCommandListener(this);

	  l2 = new List("Plateform",Choice.MULTIPLE);
	  l2.append("Linux",null);
	  l2.append("Solaris",null);
	  l2.append("NT",null);
	  l2.addCommand(backCommand);
	  l2.setCommandListener(this);

	  l3 = new List("Country",Choice.EXCLUSIVE);
	  l3.append("Thailand",null);
	  l3.append("Malaysia",null);
	  l3.append("Japan",null);
	  l3.append("Korea",null);
	  l3.addCommand(backCommand);
	  l3.setCommandListener(this);
        
        display.setCurrent(menu);
        }
        
        /**
        * Pause is a no-op since there are no background activities or
        * record stores that need to be closed.
        */
        public void pauseApp() {
        }
        
        /**
        * Destroy must cleanup everything not handled by the garbage collector.
        * In this case there is nothing to cleanup.
        */
        public void destroyApp(boolean unconditional) {
        }
        
        /*
        * Respond to commands, including exit
        * On the exit command, cleanup and notify that the MIDlet has been destroyed.
        */
        public void commandAction(Command c, Displayable s) {
        if (c == exitCommand) {
        destroyApp(false);
        notifyDestroyed();
        }else if (c == backCommand){
		display.setCurrent(menu);
	  }else if (c == List.SELECT_COMMAND){
		if(s == menu){
			switch(((List) s).getSelectedIndex()){
				case 0 : display.setCurrent(l1);
					break;
				case 1 : display.setCurrent(l2);
					break;
				case 2 : display.setCurrent(l3);
					break;
			}
		}
        }

        }
        
        }

ผลการ Run

ListDemo MIDlet
รูปที่ 37 แสดงหน้าต่าง Emulator ที่ run MIDlet ที่เขียนขึ้น

อธิบาย: โค้ดข้างต้น เป็นตัวอย่างที่แสดงถึง คุณสมบัติของ List แต่ละประเภท


ตัวอย่างที่ 5 Alert & Ticker Demo

AlertDemo.java

Download Code Download Code
/* * AlertDemo.java * * Created on 13 ??????? 2546, 16:38 ?. */
      
        import javax.microedition.midlet.*;
        import javax.microedition.lcdui.*;
      /**
        * An example MIDlet with simple "Hello" text and an Exit command.
        * Refer to the startApp, pauseApp, and destroyApp
        * methods so see how each handles the requested transition.
        *
        * @author sup98
        * @version
        */
        public class AlertDemo extends MIDlet implements CommandListener {
        
        private Command exitCommand, okCommand; 
        private Display display; // The display for this MIDlet
        private TextBox t;
        
        public AlertDemo() {
        display = Display.getDisplay(this);
        exitCommand = new Command("Exit", Command.SCREEN, 2);
        okCommand = new Command("OK", Command.SCREEN,2);

        }
        
        /**
        * Start up the Hello MIDlet by creating the TextBox and associating
        * the exit command and listener.
        */
        public void startApp() {
	  	t = new TextBox("","8116585", 10, TextField.PHONENUMBER);
		Ticker t1 = new Ticker("Enter Your Office Phone Number");

		t.addCommand(exitCommand);
		t.addCommand(okCommand);
		t.setTicker(t1);
		t.setCommandListener(this);
        
        display.setCurrent(t);
        }
        
        /**
        * Pause is a no-op since there are no background activities or
        * record stores that need to be closed.
        */
        public void pauseApp() {
        }
        
        /**
        * Destroy must cleanup everything not handled by the garbage collector.
        * In this case there is nothing to cleanup.
        */
        public void destroyApp(boolean unconditional) {
        }
        
        /*
        * Respond to commands, including exit
        * On the exit command, cleanup and notify that the MIDlet has been destroyed.
        */
        public void commandAction(Command c, Displayable s) {
        if (c == exitCommand) {
        destroyApp(false);
        notifyDestroyed();
        } if (c == okCommand){
		Alert alert = new Alert("Infomation");
		alert.setString("Your phone number is" +t.getString());
		alert.setTimeout(2000);
		display.setCurrent(alert);
	  }        

        }
        
        }

ผลการ Run

AlertDemo MIDlet
รูปที่ 38 แสดงหน้าต่าง Emulator ที่ run MIDlet ที่เขียนขึ้น

อธิบาย: โค้ดข้างต้น เป็นตัวอย่างที่แสดงถึง การทำงานของ Alert และ Ticker


ตัวอย่างที่ 6 Form Demo

FormDemo.java

Download Code Download Code
/* * FormDemo.java * * Created on 13 ??????? 2546, 16:38 ?. */
      
        import javax.microedition.midlet.*;
        import javax.microedition.lcdui.*;
      /**
        * An example MIDlet with simple "Hello" text and an Exit command.
        * Refer to the startApp, pauseApp, and destroyApp
        * methods so see how each handles the requested transition.
        *
        * @author sup98
        * @version
        */
        public class FormDemo extends MIDlet implements CommandListener, ItemStateListener {
        
        private Command exitCommand, okCommand, backCommand; 
        private Display display; // The display for this MIDlet
        private List menu;
	  private TextField tf1, tf2;
	  private Form fr1, fr2, fr3;
        
        public FormDemo() {
        display = Display.getDisplay(this);
        exitCommand = new Command("Exit", Command.SCREEN, 1);
	  backCommand = new Command("Back", Command.SCREEN, 2);
        okCommand = new Command("OK", Command.SCREEN,2);

        }
        
        /**
        * Start up the Hello MIDlet by creating the TextBox and associating
        * the exit command and listener.
        */
        public void startApp() {
	  	menu = new List("Selection", List.IMPLICIT);
	      menu.append("TextField",null);
	      menu.append("Date",null);
	      menu.append("Gauge",null);
	      menu.addCommand(exitCommand);
	      menu.setCommandListener(this);

		fr1 = new Form("Enter name");
		fr1.append("First Name");
		tf1 = new TextField("", "", 15, TextField.ANY);
		fr1.append(tf1);
		fr1.append("Last Name");
		tf2 = new TextField("", "", 15, TextField.ANY);
		fr1.append(tf2);
		fr1.addCommand(backCommand);
		fr1.setCommandListener(this);

		fr2 = new Form("Change Date");
		java.util.Date now = new java.util.Date();
		DateField dateItem = new DateField("Today's date:", DateField.DATE);
		dateItem.setDate(now);
		fr2.append(dateItem);
		fr2.addCommand(backCommand);
		fr2.addCommand(okCommand);
		fr2.setItemStateListener(this);

		fr3 = new Form("Gauge Demo");
		Gauge g = new Gauge("Level", true, 10, 0);
		fr3.append(g);
		fr3.addCommand(backCommand);
		fr3.setCommandListener(this);		
        
        display.setCurrent(menu);
        }
        
        /**
        * Pause is a no-op since there are no background activities or
        * record stores that need to be closed.
        */
        public void pauseApp() {
        }
        
        /**
        * Destroy must cleanup everything not handled by the garbage collector.
        * In this case there is nothing to cleanup.
        */
        public void destroyApp(boolean unconditional) {
        }
        
        /*
        * Respond to commands, including exit
        * On the exit command, cleanup and notify that the MIDlet has been destroyed.
        */
        public void commandAction(Command c, Displayable s) {
        if (c == exitCommand) {
        destroyApp(false);
        notifyDestroyed();
        } else if (c == backCommand){
		display.setCurrent(menu);
	  } else if ((c == List.SELECT_COMMAND)&&(s == menu)){
		switch (((List)menu).getSelectedIndex()){
			case 0: display.setCurrent(fr1);
				break;
			case 1: display.setCurrent(fr2);
				break;
			case 2: display.setCurrent(fr3);
				break;

		}

	  }       

        }

        public void itemStateChanged(Item item) {
		java.util.Calendar cal = java.util.Calendar.getInstance(java.util.TimeZone.getDefault());
		cal.setTime(((DateField) item).getDate());
        }

        
        }

ผลการ Run

Enter Name
Change Date
Gauge Demo
รูปที่ 39-41 แสดงหน้าต่าง Emulator ที่ run MIDlet ที่เขียนขึ้น

อธิบาย: โค้ดข้างต้น เป็นตัวอย่างที่แสดงถึง การทำงานของ Form ร่วมกับ Control อื่นๆ

 

BACK

คลิปสอนเขียนโปรแกรม
เรียนเขียนโปรแกรมดอทเน็ต
เรียนเขียนโปรแกรมแอนดรอยด์
เรียนเขียนโปรแกรมเบล็คเบอร์รี่
เรียนเขียนโปรแกรมซี ซีพลัสพลัส
เรียนเขียนโปรแกรมจาวา
เรียนการใช้งานลินุกส์
เรียนการเขียนโปรแกรมวินโดว์โฟน
เรียนการเขียนโปรแกรมพีเฮชพี มายเอสคิวเอล
อัตราค่าโฆษณา
 
Tutorial
eVB Tutorial
ASP.NET Webmatrix Tutorial
J2ME Tutorial
C++  Tutorial
Java  Tutorial
PHP Tutorial
ASP Tutorial
 
แบบสำรวจ

Home - Article - Tutorial - Sourcecode - Dev Handbook - Search - WebBoard - Links - About Us

สงวนลิขสิทธิ์ ห้ามคัดลอก ทำซ้ำ แก้ไข ดัดแปลง ไม่ว่าในรูปแบบใด โดยไม่ได้รับอนุญาตเป็นลายลักษณ์อักษร
เลขทะเบียนพาณิชย์อิเล็กทรอนิกส์จากกระทรวงพาณิชย์: 7100503002000
Copyright 2001 SourceCode.in.th