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 message.


 Regards
 Nibedita
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

Ads









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
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
awt in java
awt in java  using awt in java gui programming how to false the maximization property of a frame
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 Tutorials
AWT Tutorials  How can i create multiple labels using AWT????   Java Applet Example multiple labels 1)AppletExample.java: import javax.swing.*; import java.applet.*; import java.awt.*; import
StringBuffer related.
StringBuffer related.  how to make StringBuffer as immutable
AWT Image
AWT Image  I have loaded two images using toolkit in java.one is concentric rectangle and other is concentric circle.kindly someone send me the source code of interchanging the inner most rectangle with the inner most circle
java awt calender
java awt calender  java awt code for calender to include beside a textfield
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 Questions
Related Questions  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: Related Questions... "Related Questions". Also tell me which is the good training courses
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
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
another frame by using awt or swings
another frame by using awt or swings  how to connect one frame to another frame by using awt or swings
java awt package tutorial
Java AWT Package In Java, Abstract Window Toolkit(AWT) is a platform... programming language, the AWT is also platform-independent. A common set.... The implementation of the user interface elements provided by the AWT is done using
Awt programming with java
Awt programming with java  Write a java program, which provides a text area with horizontal and vertical scrollbar.Type some lines in the text area and use scrollbars to move the text within the text area.Read a word in a text
Version of com.levigo>gwt-awt dependency
List of Version of com.levigo>gwt-awt dependency
Version of com.globalmentor>globalmentor-awt dependency
List of Version of com.globalmentor>globalmentor-awt dependency
date and time in awt(java)
date and time in awt(java)  sir, do you have an example of date in awt java which can be view over a textfield.   Display time in JTextField import java.util.*; import javax.swing.*; import java.awt.event.*; public
ModuleNotFoundError: No module named 'related'
ModuleNotFoundError: No module named 'related'  Hi, My Python... 'related' How to remove the ModuleNotFoundError: No module named 'related... to install padas library. You can install related python with following command

Ads