i have one textfield and one button.when i entered text in textfield then only button should be in enabled status or else in disable status. i need code for this.

i have one textfield and one button.when i entered text in textfield then only button should be in enabled status or else in disable status. i need code for this.

i have one textfield and one button.when i entered text in textfield then only button should be in enabled status or else in disable status. i need code for this.

thankas in advance

View Answers

November 16, 2011 at 11:40 AM

import javax.swing.*;
import java.awt.event.*;
class TextFieldAndButton 
{
    public static void main(String[] args) 
    {
        JFrame f=new JFrame();
        JTextField text=new JTextField(20);
        final JButton b=new JButton("Check");
        b.setEnabled(false);
        text.addKeyListener(new KeyAdapter(){
      public void keyPressed(KeyEvent keyEvent) {
        b.setEnabled(true);
      }
      public void keyReleased(KeyEvent keyEvent) {
        b.setEnabled(true);
      }
      public void keyTyped(KeyEvent keyEvent) {
        b.setEnabled(true);
      }
    });
    text.setBounds(10,10,150,20);
    b.setBounds(10,30,100,20);
    f.setLayout(null);
    f.add(text);
    f.add(b);
    f.setVisible(true);
    f.setSize(300,100);
  }
}









Related Tutorials/Questions & Answers:
i have one txt field and one button.when i entere any test in testfield then only button should be enabled. i need for this
i have one txt field and one button.when i entere any test in testfield then only button should be enabled. i need for this   i have one txt field and one button.when i entere any test in testfield then only button should
i have one txt field and one button.when i entere any test in testfield then only button should be enabled.
i have one txt field and one button.when i entere any test in testfield then only button should be enabled.  i have one txt field and one button.when i entere any test in testfield then only button should be enabled. i need
Advertisements
I have only one day to visit the Jaipur..
I have only one day to visit the Jaipur..  Hi, I have only a day to travel in Jaipur ..hence, bit worried about what to see first
how to highlight the field in image,when i have entered into that corresponding field's textbox-any one help out
how to highlight the field in image,when i have entered into that corresponding field's textbox-any one help out  how to highlight the field in image,when i have entered into that corresponding field's textbox. Here webpage
How to disable Browser's back button (at the same time i want my own back button to be enabled) :p
How to disable Browser's back button (at the same time i want my own back button to be enabled) :p  Hi, I have designed a "back" button for jsp page. Now I want to disable Browser's default button So that people will use "back
How to disable Browser's back button (at the same time i want my own back button to be enabled) :p
How to disable Browser's back button (at the same time i want my own back button to be enabled) :p  Hi, I have designed a "back" button for jsp page. Now I want to disable Browser's default button So that people will use "back
I am creating one jsp page in which I read in a text file, then display that data in tabular format. Now I need to calculate a total.
I am creating one jsp page in which I read in a text file, then display that data in tabular format. Now I need to calculate a total.  I am reading...... } The output displays 4 rows and 2 columns. How can I calculate the total
I am new to java applets. When i run this code on applet viewer status is displayed that applet not initialized
I am new to java applets. When i run this code on applet viewer status... ActionListener { TextField tname,tpwd; Label lname,lpwd; public...:"); tname=new TextField(20); tpwd=new TextField(20
I want to Transfer only 1/3rd of contents from one folder to other but my code is transferring all contents
I want to Transfer only 1/3rd of contents from one folder to other but my code...("No files in directory: " + src); } for (int i = 0; i < entries.length; i++) { File file = entries[i
I have need to help
I have need to help  Write a program that, for four points A, B, C and P, draws a triangle formed by ABC and a small cross showing the position of P; and displays a line of text indicating which of the following three cases
I have posted a number of question but no one has answered?
I have posted a number of question but no one has answered?  No one has responded for ten days now. However my first question was answered on the same day. Is there a limit to the number of questions you can ask or am I doing
in my project, i have to add only vertical scrollbar to a panel,but not horizontal scrollbar. i need some example on it,how to doit.
in my project, i have to add only vertical scrollbar to a panel,but not horizontal scrollbar. i need some example on it,how to doit.  in my project, i have to add only vertical scrollbar to a panel,but not horizontal scrollbar
I want only one method goes to sleep but both method goes to sleep together
I want only one method goes to sleep but both method goes to sleep together  I built a TicTacToe game for android. And i want that there should...]==0) { buttons[i].setText(" "); } else if(c[i
I want only one method goes to sleep but both method goes to sleep together
I want only one method goes to sleep but both method goes to sleep together  I built a TicTacToe game for android. And i want that there should...) { buttons[i].setText(" "); } else if(c[i]==1
I have one small doubt , does this code read Microsoft Office suit file format data such as .doc , .docx etc ?
I have one small doubt , does this code read Microsoft Office suit file format data such as .doc , .docx etc ?  import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class ReadFileExample
i need program or code for this program
i need program or code for this program  out should be in this form 1 2 3 4 5 6 3 5 7 9 11 8 12 16 20 20 28 36 48 64 112
I need jsp code for how to write text field value into property file.
I need jsp code for how to write text field value into property file.  Hi , I need to set the text field value into property file using jsp code. Example : Username : Valar , I have entered the value "Valar" in the text field
I have doubt in jsp file.
on start then only stop should be enabled. Other wise it should be disabled. When we click on start button, stop should be enabled and start should be disabled. When we click on stop button, start should be enabled and stop should be disabled
i need the source code to generate id in jsp
i need the source code to generate id in jsp  hai,i need the source code for generate id...which is i need to generate the new id from the maximum+1,like automatically when i click the button...as well i have several kinds
instead of text boxe i have to show check box as selected.
instead of text boxe i have to show check box as selected.  i have one text field. in that iam getting boolean value either true or false from the database. when ever the valsue is there in textfield, instead of text boxe i
I have a tex box. in that i want user should enter data in the format specified(for eg--a_b_c_d_e_)how to write code for it.
I have a tex box. in that i want user should enter data in the format specified(for eg--a_b_c_d_e_)how to write code for it.  I have a tex box. in that i want user should enter data in the format specified(for eg--abcde_)how
how can i define only one method from the interface. - Java Beginners
how can i define only one method from the interface.  If i am having an interface with 3 methods(declaration) . If i want to use only one method... the solution for that. please i want it immediately.  Hi friend
How can I master Java in one month?
How can I master Java in one month?  Hi, I wish to learn Java programming in one month. I have little experience in c programming and PHP programming. Is there any way to learn Java quickly. How can I master Java in one month
How should I start to learn code with Java?
How should I start to learn code with Java?  Hi, I want to learn programming language and make career in software industry. I have decided to learn... should learn in Core Java. After learning core Java one has to learn the advanced
i need a java code for finding typemismatch in an editor.
i need a java code for finding typemismatch in an editor.  hi im sriram, i need a java code in such a way that typemismatch code is embedded with the simple java editor. the sample output is shown below !alt text
I need to launch multiple instances of IE browser from one windows M/C on the another windows M/C
I need to launch multiple instances of IE browser from one windows M/C on the another windows M/C  multiple instances of IE browser from one windows M/C on the another windows M/C
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
PLZ HELP ME. i need php code.
PLZ HELP ME. i need php code.   I want php code for bellow OUTPUT. output is just example but it must be letters only. abc bcd efg jku rgt azs hje qqc wws adt
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, in that email will validte by useing regular expressions?  i want validation for one text field and text area,email,combobox, in that email will validte by useing
software or i have to write a code for this suff
convert windows picture or fax viewer file into ms word or pdf   sir i want to convert windows picture or fax viewer file into ms word or pdf so for this is i have to take help from the java code or any software is present
hello there i need help
OPtions: once i have chosen an option then i should proceed here if i choose b... me with the codes and please explain to me how it works. i only need to use...hello there i need help  : i need to do a program like
I need an example of sessionfactory
I need an example of sessionfactory  Hi, I need an example of session factory in hibernate. If you can provide me one with, that would be great...Thanks
hi .. need help ASAP ..i have a project buit in eclipse , i have installed jasper. i want the steps to work on it ..
hi .. need help ASAP ..i have a project buit in eclipse , i have installed jasper. i want the steps to work on it ..   hi .. need help ASAP ..i have a project buit in eclipse , i have installed jasper. i want the steps to work
my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet
my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet  my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet. can some one help me. thx. moses
my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet
my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet  my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet. can some one help me. thx. moses
my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet
my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet  my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet. can some one help me. thx. moses
my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet
my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet  my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet. can some one help me. thx. moses
i want to copy files from one machine to other using java and the code will be running on third machine
i want to copy files from one machine to other using java and the code will be running on third machine  i want to copy some files from one machine... machine say 'c'. So , can you help me on this that how can i do this using
TextField
TextField       A scrollable text display object with one row of characters is known as the TextField. In the example given below, shown a textfield in the applet by creating its
I have crude application
I have crude application   I have crude application, how to load into this roseindia.net
i need to replace this if statement code with switch case code
i need to replace this if statement code with switch case code   i need to replace this code with switch case for(int i=0;i<100;i++){ if((i%3)==0) system.out.println("java"); if((i%5)==0) system.out.println("technology
in my project, i have to add scrollbars to a panel,. i need some example on it,how to doit.
in my project, i have to add scrollbars to a panel,. i need some example on it,how to doit.  in my project, i have to add scrollbars to a panel,. i need some example on it,how to doit. Thanks In Advance   Please
How can I learn machine learning in one day?
How can I learn machine learning in one day?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: How can I learn machine learning in one day? Try to provide me good
How do I learn Java programming in one day from zero?
. Is there any way of really learning Java in one day? How do I learn Java programming in one day from zero? I am aware of C and C++ programming language. I have used...How do I learn Java programming in one day from zero?  Hi, I am
How do I learn Java programming in one day from zero?
. Is there any way of really learning Java in one day? How do I learn Java programming in one day from zero? I am aware of C and C++ programming language. I have used...How do I learn Java programming in one day from zero?  Hi, I am
i want to display where i entered values to same page
i want to display where i entered values to same page  hi friends !! i have a values from jsp page .and i want to store that values into DB at the same time i want to show immediatlly on same jsp page with tabular format
i want to display where i entered values to same page
i want to display where i entered values to same page  hi friends !! i have a values from jsp page .and i want to store that values into DB at the same time i want to show immediatlly on same jsp page with tabular format
one error but i dont know how to fix it o_O!!!
one error but i dont know how to fix it o_O!!!  where is the mistake...+"Secends have"+houres+"houres,"+minutes+"minutes and"+new Secends+"secends"); } } the compilar told me that there is only one error... thx
i need attendce management system source code in java
i need attendce management system source code in java  i need attendance management system source code in java
i need project
i need project  can u send online shoppin project 2 my mailid.   Please visit the following links: Struts2 Shopping cart JSP-Servlet Shopping cart

Ads