Home Answers Viewqa Swing-AWT query related to awt

 
 


Nibedita Panda
query related to awt
1 Answer(s)      2 years and 4 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
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 Pages:
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
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
liferay related query
liferay related query  can you suggest me how to get all the session ids of different users logged in to liferay
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
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 - Swing AWT
java swing awt thread query  Hi, I am just looking for a simple example of Java Swing
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
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
related to database
related to database  how to override existing values in table? when user enters his updated data through query
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
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
XML Related Technologies: An overview
XML Related Technologies: An overview       Below is a list of XML-related technologies. DTD... document. XForms (XML Forms) uses XML to define form data. XQuery (XML Query
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
jdbc & sql related project - JDBC
from a list and execute any sql query related to the selected database e.g... to execute any query related to student database i.e. the odbc driver should support...jdbc & sql related project  code using jdbc,odbc,swing,MySql classes
project query
project query  I am doing project in java using eclipse..My project is a web related one.In this how to set sms alert using Jsp code. pls help me
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
computer - Swing AWT
computer  What is a Computer and why we should use it? I am new to this technologies so please let me know the benefits of using computer.   What you what to know about computers?Is it a software or hardware related
JPA delete query - EJB
to delete all the records from the table. What will be the JPA query to delete... flexible and it provides required API for perform database related operations... to achieve this: Query query = em.createQuery("delete from InvoiceItems o
Jcombo box - Swing AWT
Jcombo box  Hello sir i found dis site today...realy superb evn i complete half project with ur examples sir i hav problem related to combo box i hav 3 combox c1, c2, c3 c1 contains items A, B, C, D c2 contains items E, F, G
Java question - Swing AWT
Java question  I want to create two JTable in a frame. The data in one JTable will be shown as a result of a query i.e. the data in a resultset. This query is fixed. This query is "select * from item". Item table has following
jsp query - JSP-Servlet
jsp query  in first division there is one table which contains data with edit button... when i will click on edit button that division will become hidden and new division come with all related data
What is AWT in java
What is AWT in java      ... available with JDK. AWT stands for Abstract Windowing Toolkit. It contains all classes... toolkits. You can use the AWT package to develop user interface objects like
AWT
Java Query - Java Beginners
Java Query  Q.What is "Identifier Expected Error" in Java and when does it occur? Send me a list of causes related this error.  Hi Friend, This is the error that occurs during the compilation of a resource
Jfree chart problem - Swing AWT
Jfree chart problem  hello i have a problem related to jfree chart i have some data and i want to display data in two different chart stacked area chart and line chart both in a single frame. That is hybrid combination
StringBuffer related.
StringBuffer related.  how to make StringBuffer as immutable
Loading Manifest File - Swing AWT
someone said to me: C:\>reg query HKCR\jarfile\shell\open\command Then, I

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.