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



Home Answers Viewqa Swing-AWT i have one txt field and one button.when i entere any test in testfield then only button should be enabled. .when i cleared the test,at that time butoon should be disabled. i need code for this
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


raveen
i have one txt field and one button.when i entere any test in testfield then only button should be enabled. .when i cleared the test,at that time butoon should be disabled. i need code for this
1 Answer(s)      2 years and 10 months ago
Posted in : Swing AWT


i have one txt field and one button.when i entere any test in testfield then only button should be enabled. .when i cleared the test,at that time butoon should be disabled. i need code for this thanks in advance


Advertisement
View Answers

November 16, 2011 at 4:52 PM


import javax.swing.*;
import java.awt.event.*;
class TextFieldAndButton 
{
    public static void main(String[] args) 
    {
        JFrame f=new JFrame();
        final JTextField text=new JTextField(20);
        final JButton b=new JButton("Check");
        b.setEnabled(false);
        text.addKeyListener(new KeyAdapter(){
        public void keyTyped(KeyEvent keyEvent) {
       if((text.getText()).equals("")){
        b.setEnabled(false);
       }
       else{
        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
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
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
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
Should i use Ajax? - Ajax
Should i use Ajax?  When a Ajax can be used in programming?  Its completely up to you but there is no harm in using Ajax programming for any website as they are used to increase the speed of website. You need
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
how should i can solve
how should i can solve  Web based program - Input - Person's contact details with Passport Number as Unique Key. Save data in to oracle / MySQL. Output - List of Persons saved in the database. Technology to be used - JSP
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
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
what should i do next?? - Java Beginners
exam.Then now i have no idea about what should i do next.I like to come to the web development.I want to know which one i should study first.JSP or servlet.  i think first u should go through servlet bcoz at last ur jsp code
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 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
I have to retrieve these data from the field table
I have to retrieve these data from the field table  Hi. I have... as single values like chennai as one value, trichy as one value. and i have... chennai,trichy,kanchipuram for a single record. I have to retrieve these data from
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 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
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
which database and programming language i should choose - Framework
which database and programming language i should choose  Hi, I am implementing AVL project (Automation Vehicle Location)and It need a web site.I... good JSP programmer so i want to know which one i choose from ASP.NET and PHP
should i reboot physical server to change the JDK path in linux server
should i reboot physical server to change the JDK path in linux server  Hi i need to change the JDK path in linux server. I set the JDK path export.../bin but when i check version using $java -version, it still shows old version
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
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 be some time gap or time difference between User's turn and Computer's turn. Mean 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 be some time gap or time difference between User's turn and Computer's turn. Mean i
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 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 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
hi , i cant make this programmer , can any one help me to make it pls - Java Beginners
hi , i cant make this programmer , can any one help me to make it pls  ..., salary, address... Practically, this software (set of classes) at excution time... ? -Update record(s)? -Delete record(s)? -Make one copy of a specific text file
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
when I run exiting project that time I got error, I want solution on it?
when I run exiting project that time I got error, I want solution on it?  Error occurred during deployment: Exception while loading the app... log for details. BUILD FAILED (total time: 1 minute 20 seconds
Should I be Looking for Fashion Design Colleges?
Should I be Looking for Fashion Design Colleges? We talked about a career... are usually a dime a dozen, but you have to make sure that the one you are attending... colleges usually have a lot of connections in the fashion world and with any
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
Advertisements
 

 

 

DMCA.com