java jtextfield

Ads
 

java jtextfield

how to validate jTextField which accept only number or alphabets from keyboard....plez do help me....

View Answers

March 5, 2012 at 4:05 PM

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

class TextValidation extends JFrame{
JTextField text;
JLabel label;
JPanel p;
TextValidation(){
text=new JTextField(15);
label=new JLabel("Enter number or letter:");
p=new JPanel();
p.add(label);
p.add(text);
text.addKeyListener(new KeyAdapter(){
            public void keyReleased(KeyEvent e){

                char ch = e.getKeyChar();
                if(Character.isDigit(ch)||Character.isLetter(ch)){
                }
                else{
                    JOptionPane.showMessageDialog(null, "Only letters and numbers are allowed!");
                    text.setText(" ");
                }
            }
});
add(p);
setVisible(true);
setSize(300,100);
}
public static void main(String[]args){
TextValidation v=new TextValidation();
}
}

Ads









Related Tutorials/Questions & Answers:
java jtextfield
java jtextfield  how to validate jTextField which accept only number or alphabets from keyboard....plez do help me
JTextField Validation in java swing
JTextField Validation in java swing In this tutorial, you will learn how to validate jtextfield in java swing. Here we have created a textfield on frame... extends JFrame{ JTextField text; JLabel label; JPanel p; TextValidation(){ text
Advertisements
jtextfield
jtextfield  hii..is it possible to make a jtextfield in login page in such a way that some text should already be inserted like username and it should be displayed light in color and when a user enters some text then it should
JTextField
JTextField  simple program for text field cannot not be edited in java swing
jTextField in swing
jTextField in swing  I am new to java and i am making a registration form.i just want to know if there is any code in which a string cannot be inserted in a jtextfield where a phone number has to be inserted.the jtextfield should
Jlist and JTextfield
Jlist and JTextfield  How can we filter values from jlist by adding only a single letter in jtextfield such that when letter S is pressed in jtextfield then jlist should diplay all the values starting from letter S.I am using
float validation for jTextField
float validation for jTextField  Hi; I try that users enter only float number into jtextfield but I can not handle it. I try regex in keylistener but I couldn't be successful. Can you help me please
validate jtextfield in two different class use keylistener
validate jtextfield in two different class use keylistener  validate jtextfield in java swing will use two class, design part in one class and method calling in one class will use Keylisteners or change listeners
How to return a string from a JTextField
How to return a string from a JTextField  Hi, Am new to java, and am trying to get a string from a JTextField so that I can compare it with another...(); final JTextField text=new JTextField(20); JButton b=new JButton
easy way to make a JCombobox look like a JTextField?
easy way to make a JCombobox look like a JTextField?  Is there a good(and easy) way to make a JCombobox look like a JTextField? By this I mean.... works   Autosuggestion box in Java Swing
Copy data from one JTextField to another JTextField
Copy data from one JTextField to another JTextField..., you will learn how to copy the data from one JTextField into another JTextField. When you run this program it starts with two JTextField. Enter some
update data to mysql database through JTextField
update data to mysql database through JTextField  I am getting an error, when i am updating a data to mysql database through JTextField. Send me the code used to solve my error. public void update(){ try
How to read and retrieve jtable row values into jtextfield on clicking at particular row ...
How to read and retrieve jtable row values into jtextfield on clicking at particular row ...  Hello Sir, I am developing a desktop application in which i have to display database records in jtable .now I want
java
java  how to connect with dbms using a query in button of java program?   Here is an example that creates a form in java swing. When... panel; JLabel label1,label2,label3,label4,label5; final JTextField
java
java  how to connect with dbms using a query in button of java program?   Here is an example that creates a form in java swing. When... panel; JLabel label1,label2,label3,label4,label5; final JTextField
java
java  how to connect with dbms using a query in button of java program?   Here is an example that creates a form in java swing. When... panel; JLabel label1,label2,label3,label4,label5; final JTextField
java
java  how to connect with dbms using a query in button of java program?   Here is an example that creates a form in java swing. When... panel; JLabel label1,label2,label3,label4,label5; final JTextField
java
java  how to connect with dbms using a query in button of java program?   Here is an example that creates a form in java swing. When... panel; JLabel label1,label2,label3,label4,label5; final JTextField
java
java  how to connect with dbms using a query in button of java program?   Here is an example that creates a form in java swing. When... panel; JLabel label1,label2,label3,label4,label5; final JTextField
java
java  how to connect with dbms using a query in button of java program?   Here is an example that creates a form in java swing. When... panel; JLabel label1,label2,label3,label4,label5; final JTextField
java
java  how to connect with dbms using a query in button of java program?   Here is an example that creates a form in java swing. When... panel; JLabel label1,label2,label3,label4,label5; final JTextField
java
java  how to connect with dbms using a query in button of java program?   Here is an example that creates a form in java swing. When... panel; JLabel label1,label2,label3,label4,label5; final JTextField
java
java  how to connect with dbms using a query in button of java program?   Here is an example that creates a form in java swing. When... panel; JLabel label1,label2,label3,label4,label5; final JTextField
java
java  how to connect with dbms using a query in button of java program?   Here is an example that creates a form in java swing. When... panel; JLabel label1,label2,label3,label4,label5; final JTextField
java
java  how to connect with dbms using a query in button of java program?   Here is an example that creates a form in java swing. When... panel; JLabel label1,label2,label3,label4,label5; final JTextField
java
java  how to connect with dbms using a query in button of java program?   Here is an example that creates a form in java swing. When... panel; JLabel label1,label2,label3,label4,label5; final JTextField
java
java  how to connect with dbms using a query in button of java program?   Here is an example that creates a form in java swing. When... panel; JLabel label1,label2,label3,label4,label5; final JTextField
java
java  how to connect with dbms using a query in button of java program?   Here is an example that creates a form in java swing. When... panel; JLabel label1,label2,label3,label4,label5; final JTextField
java
java  how to connect with dbms using a query in button of java program?   Here is an example that creates a form in java swing. When... panel; JLabel label1,label2,label3,label4,label5; final JTextField
java
java  how to connect with dbms using a query in button of java program?   Here is an example that creates a form in java swing. When... panel; JLabel label1,label2,label3,label4,label5; final JTextField
JAVA
AT THE RUN TIME EITHER USING SWING OR APPLET IN JAVA BUT NOT AS JAVA SCRIPT" Thanks sowmiya.R   Here is a java swing code that displays background image...: "); JTextField text1=new JTextField(10); JTextField text2=new JTextField(10); JButton b1

Ads