Java Programing laungage

R4R® Java J2ME J2ME BASIC TUTORIALS
J2ME Projects

J2ME Project 1

AltStyle によって変換されたページ (->オリジナル) /

(追記) (追記ここまで)
(追記) (追記ここまで)
Creating a J2ME Application for addButton into Form

Application for addButton into Form

CommandThe Commands may be implemented in any user interface construct that has semantics for activating a single action.

Command command= new Command(lable, commandType, priority);

label = The label strings are what the application requests to be shown to the user to represent this command

commandType = The application uses the command type to specify the intent of this command

Priority = The application uses the priority value to describe the importance of this command relative to other commands on the same screen. Priority values are integers, where a lower number indicates greater importance.

Button Program

/*
 * Save as a addButton.java
 */
package r4r.Mobile.Basic;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
/**
 * @author R4R
 */
public class addButton extends MIDlet implements CommandListener {
 /* -- private field -- */
 private Form form;
 private Display display;
 private Command exit, select, help, back;
 /* -- Default constructor -- */
 public addButton() {
 display = Display.getDisplay(this);
 /* -- initialized field -- */
 form = new Form("Add Button into form");
 select = new Command("SELECT", Command.OK, 1);
 exit = new Command("EXIT", Command.EXIT, 1);
 help = new Command("HELP", Command.HELP, 2);
 back = new Command("BACK", Command.BACK, 2);
 /*-- Add button into form --*/
 form.addCommand(select);
 form.addCommand(help);
 form.addCommand(back);
 form.addCommand(exit);
				
 /* -- Add button functionality -- */
 form.setCommandListener(this);
 }
 public void startApp() {
 display.setCurrent(form);
 }
 public void pauseApp() {
 }
 public void destroyApp(boolean unconditional) {
 }
 public void commandAction(Command c, Displayable d) {
 if (c == exit) {
 destroyApp(true); // invoked MIDlet to terminate state
 notifyDestroyed(); 
	// notify to application management software that MIDlet
	//has entered into Destroyed state.
 } else if (c == select) {
 // Add select button listner functionality. 
 } else if (c == help) {
 // Add help button listner functionality. 
 } else if (c == back) {
 // Add back button listner functionality. 
 }
 }
}
(追記) (追記ここまで)
output
(追記) (追記ここまで)
Copyright ©2021-22 r4r.co.in, all rights reserved. Theguestspost.com
Sitemap
Career
Post comment
About us
Subscription
Unsubscription