Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Swing-AWT query related to awt

Have Programming Question? Ask it here!
 
 
 


Nibedita Panda
query related to awt
1 Answer(s)      3 years and 6 months ago
Posted in : Swing AWT


Hi,

I want to know how to check a text value is numeric or not  when user enters  the text to the textbox.After checking whether the enter text is numeric we need to display in LwDialog showing proper message.


 Regards
 Nibedita

Advertisement
View Answers

January 22, 2011 at 11:57 AM


Hi Friend,

Try this:

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.regex.*;

public class CheckTextFieldValue extends Frame{
    CheckTextFieldValue(){
    Label lab=new Label("Enter Numeric Value: ");
        final TextField text=new TextField(20);
        Button b=new Button("Check");
        lab.setBounds(20,50,150,20);
        text.setBounds(180,50,150,20);
        b.setBounds(180,80,80,20);
        setLayout(null);
        add(lab);
        add(text);
        add(b);
        setSize(350,130);
        setVisible(true);
        b.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
            String input=text.getText();
            Pattern p = Pattern.compile("[A-Z,a-z,&%$#@!()*^]");
            Matcher m = p.matcher(input);
            if (m.find()){
            JOptionPane.showMessageDialog(null,"Invalid Number!\nYou must enter only digits between 0 and 9","Error",JOptionPane.ERROR_MESSAGE);
            text.setText("");
            }
            }
        });
    }
    public static void main(String[] args){
        new CheckTextFieldValue();
    }
            }

Thank



Related Tutorials/Questions & Answers:
query related to awt
query related to awt  Hi, I want to know how to check a text value is numeric or not when user enters the text to the textbox.After checking whether the enter text is numeric we need to display in LwDialog showing proper
JDBC related query
JDBC related query  How to merge two resultset of two different queries, wherein both the resultset(after query execution)gives an integer value as its column
Advertisements
query related to jdbc
query related to jdbc  hello, i have done my database connection successfully ie db2 with RAD. but while running my application i am not able to fetch the data so please suggest and help me
query related to uploading file
query related to uploading file  hello friends i am doing my project in servlet and i want to upload a file and store file in local hard drive and file name and path in oracle database.with name file name and path i also want
liferay related query
liferay related query  can you suggest me how to get all the session ids of different users logged in to liferay
database related query
database related query  i have created database in phpmyadmin of wampserver ! but i can't see it in mysql command line ! Can anybody please help me
Hibernate Query related
Hibernate Query related  Actully i want to retrieve data from multiple file by using this query: SELECT a.PROD_ID AS Product_Id, b.PROD_N AS Product_Name, c.MEDIA_URL AS Image_url, d.SAL_AMT AS Product
query related to roseindia example - Ajax
query related to roseindia example  http://www.roseindia.net/ajax/File-Upload.shtml In FileUploadServlet.java where is "fileupload package" I am getting error on "import org.apache.commons.fileupload.disk.DiskFileItemFactory
Frame related query - Java Beginners
Frame related query  hi..... i m having a query dat...can i open a frame inside another frame like dis.. m a new biginner of java n m finding it very intresting. my lines of codes are like dis:- import java.awt.*; import
query - Swing AWT
java swing awt thread query  Hi, I am just looking for a simple example of Java Swing
Date related query - Date Calendar
Date related query  hi, m a new biginner of java.i m intrested in finding out d difference in d two dates "in terms of number of days "entered by d user using bufferedReader. how can i convert a string into a date object.pls
Query on Java Swing - Table Cell Issue - Swing AWT
Query on Java Swing - Table Cell Issue  Hi, I have a query on Java Swing. we are using swing in our application, In one of the frame we are using JTable which has 6 columns which are editable. When I use the TAB button from
AWT
AWT  How to set size of button in awt
awt
Java AWT Applet example  how to display data using JDBC in awt/applet
awt
JDBC and AWT to display data  how to display data using JDBC in awt/applet
awt
JDBC in awt applet  how to display data using JDBC in awt/applet
awt
JDBC in awt  how to display data using JDBC in awt/applet
related to database
related to database  how to override existing values in table? when user enters his updated data through query
StringBuffer related.
StringBuffer related.  how to make StringBuffer as immutable
Related to Histogram
Related to Histogram  hi this is srinivasrao. In my project i have to display using chart for that i want to use histogram. k chart displayed but the values given by me is not related display chart so please give the code if u
related to java
related to java  what is mean of }); in java.i know that } is used to close a block of statement,) is used to close a statement and ";"is used after close a statement but i can not usderstood the use of }); together in a java
Related to XML
Related to XML  I have made a web application which send the SMS, i have provided the url in which i have to save the msg and the number's(to whom the message to be send).After fetching the message and numbers i was keeping
Related to XML
Related to XML  I have made a web application which send the SMS, i have provided the url in which i have to save the msg and the number's(to whom the message to be send).After fetching the message and numbers i was keeping
Related to Project
Related to Project  how speech to text project can be make in java? Please tell me the coding part therapeutically i know i have to use java speech api which offer two technology 1. speech recognization 2. speech syenthesis
AWT & SWING
AWT & SWING  What is diffennce between AWT & SWING
AWT programmes - Swing AWT
AWT programmes  I need few programs for menus in AWT. how to open a filed dialog window, and how to save a image in the save window when we press... has all AWT programms which must open,save and make changes to a particular
AWT-swings tutorial - Swing AWT
AWT-swings tutorial  hello sir, i am learnings swings and applets.. i want some tutorials and some examples related to swings.. thank you sir..waiting for your answer.  Hi friend, I am sending you a link
awt in java
awt in java  using awt in java gui programming how to false the maximization property of a frame
Java AWT
Java AWT  What interface is extended by AWT event listeners
awt jdbc
awt jdbc  programm in java to accept the details of doctor (dno,dname,salary)user & insert it into the database(use prerparedstatement class&awt
awt - Swing AWT
awt  dear sir my proble is , i have applet code which is stock market chart this code made using "AWT" . in this chart one textbox when user.../java/awt/ Thanks
Java AWT
Java AWT  What is meant by controls and what are different types of controls in AWT
Dumps related to weblogic certification
Dumps related to weblogic certification   I want to perform the weblogic certification exam code 1z0-110. Can anybody please provide me the dumps related to 1z0-110 Thanks in advance
question related to overloading
question related to overloading  what is difference between function overloading & method overloading
question related to overloading
question related to overloading  what is difference between function overloading & method overloading
Java and jvm related question
Java and jvm related question  What is difference between java data types and jvm data types
awt swings - Swing AWT
awt swings  hello sir, My requirement is to insert captured image from cam onto a frame and from that place i hve to save it in the database(MySql).its urgent sir.it is a part of my project..if code is available
Java Related Question
Java Related Question  hi, Why java doesn't has primitive type as an object,whats an eligibility to have a primitive type as an object by the languages
Server Related exception
Server Related exception  How will write code to handle serverside exceptions in our projects.Earlier we dont know which exception the code will throw
Question related to Hibernate
Question related to Hibernate  Why do we use Set in child class in 1:many hibernate ,why can't we use Directly HashSet
Database related issue - Development process
Database related issue  I have view in db2 database and i am firing a select query on this view with two timestamps which fetches all the rows... fetched by previously running the select query on this view. Please can somebody
project related question
project related question  1- how to insert a date through hibernate 2- how to insert exact time ,date separetly in the data base for current time date
iphone property list related
iphone property list related  question related to iphone application...... how to retrieve data from plist and again check the condition if data is found in plist then go to next view and print those value in table
string related question
string related question  *q.1>how i dispaly the reference of string variableS ? eg:-String s1="my name"; Sring s2="your name"; here what is address of variable s1 and s2
problem related to onSubmit() method
problem related to onSubmit() method  Hello, I am developing application.when i submit form at that time formBacking() method is call...Instead of that onSubmit() should have to call .... please help me
Struts related Question
Struts related Question  Hi All, I have a one question on validation framework for client side validation please help me on that. suppose i don't want to put required=true in our JSP then what will happen. what error will come
java related question
java related question  How can we make a program in which we make mcqs question file and then make its corresponding answer sheet....like if we make 15 mcqs then java should generate it answer sheet of 15 mcqs with a,b,c d
Window.open Method Related.
Window.open Method Related.  sir, i use to window.open method to popup window its works easily but when windows popped up at that time i want to disabled part, except popup window look like when alert(), prompt(). or other site
java question related to objects
java question related to objects  what is the output of the following code? public class objComp { Public static void main(String args[]) { Int result = 0; objComp oc= new objComp(); object o = oc; if( o==oc) result =1; if(o
related to multiple thread....!!!!
related to multiple thread....!!!!  Write a Java program, which creates a linklist for Employees info viz. EmpID, EmpName, EmpAge. All operations should be performed on the linklist, like; Create, Add, Delete, Update, Size
 

 

 

DMCA.com