Comment

aditya
sfde,
October 11, 2008 at 11:38 AM

Text Field Midlet Example


This example illustrates how to insert text field in your form. We are using here two TextField (name and company). We are taking both TextField variable in to the constructor (TextFieldExample) of the class. When application will be run then first of all the startApp() method will called and it display the form with name and company field. The TextField is in the javax.microedition.lcdui package, has the following methods:

delete(int offset, int length)
getCaretPosition()
getChars(char[] data)
getConstraints()
getMaxSize()
getString()
insert(char[] data, int offset, int length, int position)
insert(String src, int position)
setChars(char[] data, int offset, int length)
setConstraints(int constraints)
setMaxSize(int maxSize)
setString(String text)
size()
Application display as follows:











Source code of TextFieldExample.java is as follows:

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

public class TextFieldExample extends MIDlet implements CommandListener{
private Form form;
private Display display;
private TextField name, company;
private Command ok;

public TextFieldExample(){
name = new TextField("Name:", "", 30, TextField.ANY);
company = new TextField("Company Name:", "", 30, TextField.ANY);
ok = new Command("OK", Command.OK, 2);
}

public void startApp(){
display = Display.getDisplay(this);
Form form = new Form("Text Field");
form.append(name);
form.append(company);
form.addCommand(ok);
form.setCommandListener(this);
display.setCurrent(form);
}

public void pauseApp(){

}

public void destroyApp(boolean destroy){
notifyDestroyed();
}

public void showInput(){
display = Display.getDisplay(this);
String n = name.getString();
String c = company.getString();
Form form = new Form("Input Value");
form.append(n);
form.append(c);
display.setCurrent(form);
}


public void commandAction(Command c, Displayable d) {
String label = c.getLabel();
if(label.equals("OK")){
showInput();
}
}
}


View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Java Beginners

text field
text field  How to retrieve data from text field   Hi Friend, Try the following code: import java.awt.*; import javax.swing.*; import java.awt.event.*; class RetrieveDataFromTextFields{ public static void main 

Mobile Applications Questions

J2ME
J2ME  how to create table using four field in RMS 

SQL Question

converting field to text sql
converting field to text sql  I wanted to convert the field to TEXT in SQL.. is it possible?   SQL - Converting the field to TEXT works... the field to TEXT works SELECT CONVERT(TEXT,fld_name) FROM TABLE_NAME 

Java Server Faces Questions

jsf text field not blank
jsf text field not blank  text field not clear in jsf onclick of reset button in my application initial value not deleted   Hello Friend, Post your code. Thanks 

Mobile Applications Questions

validate text field iPhone
validate text field iPhone  i got two different UITextfield in my iPhone application for user login. Just wondering how to validate 

Development process Questions

J2ME
J2ME  What is the source code for Mortgage Calculator. using text fields are home price,loan amount,down payments,down payment percent, Annual tax... in J2ME language for Symbian developing. so please help me 

Swing AWT

CALULATION IN TEXT FIELD
CALULATION IN TEXT FIELD  Suppose 3 text Field first amount ,second amount and third sum of these amount,this amount will appear when tab in next filed(i don't want use any type button) in java swing HOW? PLEASE HELP 

Blog

Sitemap J2ME Tutorial
|  Text Field MIDlet J2ME | J2ME Contact List | Date Field MIDlet J2ME... | Player Class in J2ME | Draw arc in J2ME | Building a J2ME sliding menu with text... URL | Text MIDlet J2ME | Arc MIDlet J2ME | Simple Line Canvas J2ME 

Java Beginners

swing text field problem
swing text field problem  I want to navigate the content of text field from one class to another and viceversa through button but when I am getting the text from first class I am getting null value.please help me..here 

Java Beginners

swing text field problem
swing text field problem  I want to navigate the content of text field from one class to another and viceversa through button but when I am getting the text from first class I am getting null value.please help me..here 

JSP Servlet Questions

Digit Only text field
Digit Only text field  How should we accept digits only in a textbox? (using JSTL only, without Javascript 

Java Beginners

Text field save as word file
Text field save as word file  Dear experts At run how to save set of text field contains text into single Word file. To save in our desktop computer. Solve my problem 

Spring Framework Questions

clearing text field in spring form
clearing text field in spring form  hi, I have spring form in that i have security question dropdown field and security answer text field ,when i submitted form with errors the answers text field value should be clear, for this i 

JSP Servlet Questions

rich text field - JSP-Servlet
rich text field  Hi, this is jawahar. my question i need rich text field in my program . plz send me the code 

Tutorials

iPhone Text Field Border 
Text Field Boarder  In this tutorial will learn about the text field Boarder, we can set the boarder of text field by selecting the text field... for the text field. This project is View Based Application and here will take four text 

Java Beginners

text field validation - Java Beginners
text field validation  hi How to validate allow only decimal number in text box in jsp?  Hi Friend, Try the following code: function isDecimal(str){ if(isNaN(str) || str.indexOf(".")<0){ alert 

HTML Tutorial

Text Field in HTML
Text Field in HTML       The Text Field in HTML are one line areas, which enable the user... Text Field in HTML.In this Tutorial, the code create a text field in HTML page 

Swing AWT

focus text field - Swing AWT
focus text field  i want to move cursor to next text field by pressing enter.i have created the following coding. but it does nt working.pls help me.thanks in adv. package labwork; import java.awt.KeyboardFocusManager 

Swing AWT

focus text field - Swing AWT
focus text field  i want to move cursor to next text field by pressing enter.i have created the following coding. but it does nt working.pls help me.thanks in adv. package labwork; import java.awt.KeyboardFocusManager 

Servlet Interview Questions

regarding out put display in html text field
regarding out put display in html text field  how to dispaly the output coming from servlet in a particular text field of html 

Struts Questions

Can i insert image into struts text field
Can i insert image into struts text field  please tell me can i insert image into text field 

Java Beginners

JSP combo and text field related questio
JSP combo and text field related questio  in JSP,i had stored data from database in a textboxes usin combo..now i want to use these values of text... and name given to that text field..but its showing somethimng null pointer exception 

Mobile Applications Questions

How to Define Text Field Validation iPhone
How to Define Text Field Validation iPhone  Hi, Can anybody explain me how to define textfield validation iPhone program. please phone online help reference or example. Thanks 

Tutorials

iPhone Text Field Validation
iPhone Text Field Validation In any user based application "... data from user. In this tutorial we are going to limiting the text field input...;. We have also take a Text field on the view to take the input from user 

JSP Servlet Questions

fetch values from database into text field
fetch values from database into text field  please provide the example for fetching values from database into text field of table as if i am... "rs.getString" in the text field also..   import java.awt.*; import 

JSP Servlet Questions

fetch values from database into text field
fetch values from database into text field  please provide the example for fetching values from database into text field of table wth edit...;/td>"); the i am getting "rs.getString" in the text field also..   

Java Beginners

set text field appearance to default - Java Beginners
set text field appearance to default  hi, i am doing a program, in which i have a form for the user to input some data. i wanted to change the border color of a text box if the input was incorrect, but when i fail to set 

JSP Servlet Questions

retrive record from the text field and insert into to database
retrive record from the text field and insert into to database  the following code is inserting values in the my sql database but i want to insert... ServletException,IOException{ response.setContentType("text/html 

JavaScript Questions

Unique field
Unique field  I have created a form where I have a textbox and a button. When I write something in the textbox and click on submit,it should go to database but at the same time, it should give an alert if the text entered 

HTML Tutorial

Use of Text Field
Use of Text Field, Text box, Text Area, Checkbox,Dropdownlist and Radio... types of information. A form contains form elements checkbox, text field, radio...;/form> Text Fields: Text fields are used to allow 

J2EE

Text Field Midlet Example
Text Field MIDlet Example       This example illustrates how to insert text field in your form... the form with name and company field. The TextField 

HTML Tutorial

Password Field in HTML
displays asterisks or bullets instead of the characters. Password text field is same as text field. The only difference between them is that when a user entered... illustrates a username and password text field. <form action> :The page 

Java Interview Questions

Write an applet program to transfer the content of the text field into the component on clicking a button
Write an applet program to transfer the content of the text field into the component on clicking a button  Write an applet program to transfer the content of the text field into the component on clicking a button 

Spring Framework Questions

spring form field clearence
giving wrong format validation occurs but the field remains in that text field, I want clear the text field after validation occurs...spring form field clearence  hi, I have spring form application 

Java Server Faces Questions

Retrive data from databse to a text field - Java Server Faces Questions
Retrive data from databse to a text field  Hi, Can you give me a source code to rertrve data from Mysql databse to a text field using JSF.....by selecting option from a dropdown option 

General

Text Example in J2ME
Text Example in J2ME       In J2ME programming language canvas class is used to paint and draw the diagrams. Using the same canvas class we are going to draw a box around the text 

Mobile Applications Questions

J2ME - MobileApplications
J2ME  Hi, I wanted to ask that if i want to add Select Language option in my mobile application, can i do that and if yes how? Also if its possible then will my text change in to the language i have selected or i have to write 

JSP Servlet Questions

Fetched Record from database show into text field of html page
Fetched Record from database show into text field of html page  hi, i have a database with field merchant_code, merchant_name, city, region... in the text field of merchant name then suggest all merchant name in the form 

Programming Tutorials

Show text field & check input using jQuery
Show text field & check input using jQuery In this tutorial, we will discuss about how to display 'text field' by a button click & check... how to display 'text field' by a button click & check input using 

Struts Questions

File Upload in struts2 - Invalid field value for field
File Upload in struts2 - Invalid field value for field   Hi I am... : Invalid field value for field "upload". My webContents->Web-Inf->lib...="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1 

JSP Servlet Questions

javascript cal code for selecting date in text field - JSP-Servlet
javascript cal code for selecting date in text field  HI I want javascript calendar code to select date in text field in jsp.pls send me?  Hi Friend, Please visit the following links: http://www.roseindia.net 

Java Beginners

File format validation and text field validation in java swings
File format validation and text field validation in java swings   i am reading a jpg image file throuh jfilechooser in java swings,when we press browse button for selecting file it will display filechooser in this process when 

Struts Questions

Can not input value into text field which use sx:datetimepicker
Can not input value into text field which use sx:datetimepicker  I am using lib: struts2-dojo-plugin-2.2.3.1.jar. My source is below: I input value from calendar, it runs normal. But i input value from keyboard by hands 

Struts Questions

Can not input value into text field which use sx:datetimepicker
Can not input value into text field which use sx:datetimepicker  I am using lib: struts2-dojo-plugin-2.2.3.1.jar. My source is below: print("<sx:datetimepicker name="info.date1" id="date1" displayFormat="yyyyMMdd HHmmss 

Mobile Applications Questions

J2ME jpeg image
J2ME jpeg image  Within the property window of a JPEG image, there is a tab called 'Summary'. Within this tab, there is a field called 'Comments' I would like to write some j2me code which will add a given string to this field 

Struts Questions

Validating the password field
to the registration page the password field get cleared there by asking again one more time to enter the password field at the time of re-submitting the form *newuser.jsp* <%@page contentType="text/html" pageEncoding="UTF-8"%> < 

HTML Questions

i want validation for one text field and text area,email,combobox, in that email will validte by useing regular expressions?
i want validation for one text field and text area,email,combobox... for one text field and text area,email,combobox, in that email will validte by useing...; Enter Name: <input type="text" name="name" size="30 

Java Interview Questions

how to perform a validation for the field
="text" name="name" size="30"><br> Enter an Email Address : <input type="text" name="email" size="30"><br> Enter Address 

Java Interview Questions

how to perform a validation for the field
="text" name="name" size="30"><br> Enter an Email Address : <input type="text" name="email" size="30"><br> Enter Address 

J2ME

J2ME Text Box Example
J2ME Text Box Example       This application illustrates how to create the text box using TextBox class. The TextBox class is a Screen that allows the user to enter and edit text 

Tutorials

iPhone Input Field, iPhone Input Field Tutorial
the users.  In iPhone application we can use Text Field to take the input.  Text field displays editable text and once you taps it'll display a keyboard.... And now place labels and Text Field according to your requirement. I have taken 

J2ME

J2ME Tutorial
in which the application runs.     Text Field MIDlet Example This example illustrates how to insert text field in your form. We...; Building a J2ME sliding menu with text and images(part-2) In the given J2ME Menus 

Java Beginners

How to make a list from file text in J2ME - Java Beginners
How to make a list from file text in J2ME  I was trying to make a method that read file from text and make a list of it, I have tried ReadHelpText method and want to make some improvement, I've tried like this private String 

Java Magazine Questions

j2me coding - Java Magazine
j2me coding  hi, i am doing a project on text steganography in sms using j2me. i have a problem in coding for sending and receiving sms .i have... a coding for sending and receiving sms in j2me 

Java3D Questions

regarding J2ME - Java3D
regarding J2ME  I have a problem. I have to write a 200line text... ,in j2me has various controls textfield,combobox..etc so   hi use textarea control ,in j2me has various controls textfield,combobox..etc so any 

Struts 2 Tutorials

Example of struts2.2.1 field validator.
Example of struts2.2.1 field validator. In this section, you will see the use how to validate form field or user input in struts2. Struts2 used a xml... for defining validator in XML file. Field validator Non-field validator 

Mobile Applications Questions

j2me
j2me  i need more points about j2me 

Java Beginners

j2me
j2me  how to compile and run j2me program at command prompt 

Java Beginners

j2me
j2me  why we extends class MIDlet in j2me application 

SQL Question

j2me problem - SQL
j2me problem  Hi i hava a j2me (mobile application) having 3 forms each one having 4 fields(text box and dropdown ).i want to get the data from thouse fields, and store into sql data base in my local pc. How intract 

Java Interview Questions

how to move curosr from one text field to another automatically when the first textfield reaches its maximum length
how to move curosr from one text field to another automatically when the first textfield reaches its maximum length  how to move curosr from one text field to another automatically when the first textfield reaches its maximum 

Tutorials

iphone text field example
in this application, First 2 takes the input from the user and the last text field prints the added values of above text fields into it on button click(Submit button... readable. Now go to Tools->Inspector->Text Field Attributes-> Interaction 

Java Beginners

J2ME count character into string
J2ME count character into string  i am new in J2ME, my problem is how... and got nothing...some one plz give me a punch :) as an example, 1. i got a text... with J2ME coding, tons of thx will be given :) best regards, Noob beginner   

JSP Servlet Questions

j2me
j2me  I need fifth sem MCA mobile computing lab programs using j2me. i m beginner for j2me and i want to know how to run j2me programs. pls help 

Design concepts & design patterns Questions

j2me
j2me  how to use keylistener in j2m 

Mobile Applications Questions

J2ME
J2ME PROGRAM TO CONNECT WITH MS-ACCES  HI WRITE A J2ME PROGRAM TO CONNECT WITH MS-ACCESS.(CREATING DATABASE) THANKS 

Java Magazine Questions

j2ME
j2ME  give a sample example for using key listener in j2ME for developing Symbian 

Design concepts & design patterns Questions

J2ME
J2ME  Hi, what is the source code for Mortgage Calculator in J2ME for Developing Symbian 

Java Beginners

J2me
J2me  How to run j2me program in Wireless tool kit   Hi Friend, Please visit the following link: J2ME Tutorials Thanks 

Development process Questions

j2me
j2me  hi, in j2me does any click events for developing Symbian.? and How to add click event for dynamically generated button in j2me on Symbian OS 

Mobile Applications Questions

J2ME
J2ME  Dear Sir, Am beginner of j2me am asking so many times but still now i didn't get a reply for you...I want source code to scan a image and upload to server in j2me also QR Code decoding in j2me thanks and regards 

Java Beginners

J2ME
J2ME  WHEN WILL repaint() of CustomItem will call automatically 

Development process Questions

j2me
j2me  hi, i'm working emulator in j2me language, for Symbian OS (Nokia) development. then, what are the click events in this for developing the application.? Thank you 

Development process Questions

j2me
j2me  hi, how to use LWUIT in emulator J2me for Symbian OS? and also how to install in emulator, did worked 

Development process Questions

j2me
j2me  Hi, how can add image in forms but using lick a button. does not using canvas in j2me for Symbian development 

JavaScript Questions

automatically move next page when data fetched from database is stored in text field
automatically move next page when data fetched from database is stored in text field  hi I have php page where i have two text fields . The data are stored in database wherein when the in the first text field the data is already 

Java Beginners

j2me
j2me  hey i m doing a project can i create message reader using j2me in nokia phone?? pls give me source code or hint 

Mobile Applications Questions

J2ME
J2ME  hi i am just stared j2me learning. can you please tell me how to put radio button and textFiled at same row 

Java Beginners

j2me
j2me  in j2me i want to know how to acess third form from the second form.... so need a program for example with more thaan three form 

Java Beginners

j2me
j2me  in j2me i want to know how to acess third form from the second form.... so need a program for example with more thaan three form 

Java Beginners

J2ME
J2ME  Hi friends, i have display the bar code image from Mysql database to web page i need to display that image in my J2ME application,how 

Java Beginners

J2ME
J2ME  how to change the color of the selected date using J2ME. i.e. if i press select by taking the cursor on the date ,the color of that digit should change 

Java Interview Questions

J2ME
J2ME  how to use form and canvas is same screen in J2ME   Hi Friend, Please visit the following link: http://www.roseindia.net/j2me/CanvasForm.shtml Thanks 

Java Beginners

J2ME
J2ME  how to accept time in textField using constraints in case of J2ME   Hello Friend, Please visit the following link: http://www.roseindia.net/j2me/date-field.shtml Thanks 

Servlets-Tutorials

Java Servlet : Hidden Field
Java Servlet : Hidden Field In this tutorial, we will discuss about Hidden Field. It is one of session tracking technique. Hidden Field : Session... field, Cookies, URL rewriting. Hidden form field is a way of session tracking 

Java Beginners

J2ME
J2ME  Hi sir, i need a source code for simple calculator along with buttons in mobile application 

Java Beginners

J2ME
J2ME  how to get the color of a pixel in J2ME but not in Java... J2ME. I am using Canvas. I needed to know, if there is any method to get... line using J2ME 

Java Beginners

j2me
j2me  COmmand c=new Command("Exit",Command.EXIT,100);Please expalin abt 3 parameters 

Java-Tutorials

Java Password Field
of text field which allows to enter password only. Due to the security reason... the wrong entry in either of the text field or password field and then if you...Java Password Field In this section we will discuss how to use password field 

Development process Questions

J2ME
J2ME  i am working in j2ME language on Symbian OS S60 (Nokia)application in this application i am adding buttons for designing in MIDlet application. so how to add button in dynamically. and how can place lancher icon also 

Java Beginners

J2ME
J2ME -i want to execute j2me program using sun wireless tool kit 2.5.2 pls suggest me which WTK for 64 bit operating system  hello sir, i am using windows 7 64 bit in my laptop...,i want to execute j2me program using sun wireless 

Ajax Questions

how can retrieve more than one values in text field using ajax?
how can retrieve more than one values in text field using ajax?  im... first then in mysql db retrieve seat numbers 1,2,3,4 in text boxes problem...($result)) { echo "<input name='seat' type='text' value=".$row['Seat_Number 

JSP Servlet Questions

j2me
j2me  i want code in which when we input same data in midlet page ... than on ok button it will show in servlet page.. code that pass information to mobile application page to servlet page 

Mobile Applications Questions

j2me
j2me  i want code in which when we input same data in midlet page ... than on ok button it will show in servlet page.. code that pass information to mobile application page to servlet page 

Java Beginners

j2me
j2me  hi i'm a java beginner and i am working in j2me. i am using java wireless tool kit and java sdk. and the problem is that i am not getting the out put in the java sdk. for the source code provided by you. please give me 

Development process Questions

j2me
j2me  Hi, i'm working eclipse j2me for Symbian development. i want a combo box use like a scroll bar type. when we are using combo box to a column it acts as one combobox for all cells in a column but i nedd separate combobox 

Development process Questions

j2me
j2me   Hi, In my j2me application I have used canvas to display an image in fullscreen.In the image there are four points( rectangular areas ). Now I have to add events to these points. It looks like that those areas will be used 

JSP Servlet Questions

form field mapping with pdf file using java
file. means, if click on text field according that perticular field .the data related to the field in pdf file should marked with a color. can any one give...form field mapping with pdf file using java   Hai all, I have one 

HTML Questions

textfield selected text
textfield selected text  How to select text in text field 

Java Beginners

j2me
j2me  What is JAD file what is necesary of that   Hi Friend, Please visit the following link: JAD File Thanks   Hi Friend, Please visit the following link: JAD File Thanks 

Advertisements Advertisements
 

 

 

DMCA.com