Enable and Disable JTextField using setEnabled(Boolean boolean) Method

This code example shows how to use JTextField setEnabled method.We can use this method to enable or disable JTextField.Disabled JTexField ...

This code example shows how to use JTextField setEnabled method.We can use this method to enable or disable JTextField.Disabled JTexField does not allow input from users.

Syntax

  field.setEnabled(false);

JTextField setEnabled Example

/**
 *
 * @author Eric
 * Blog:www.techoverload.net
 * This Example shows how to Enable and Disable JTextField using 
 * setEnabled(boolean) method
 */

   To make the field enabled we set 
   field.setEnabled(true);
   
   */
import javax.swing.JFrame;
import javax.swing.JTextField;
import java.awt.Dimension;
import java.awt.FlowLayout;
public class JTextFieldExample  extends JFrame{
    public JFrame frame;
    public JTextField field;
    JTextFieldExample()
    {
   super("JTextField methods");
   setLayout(new FlowLayout());
    //create JTextField object
    field=new JTextField();
    field.setColumns(30);
   /*Set JTexField.setEnabled(false);
    */
   field.setEnabled(false);
 
      add(field);
    //=======================
     setSize(new Dimension(300,300));
     setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     setVisible(true);
    
    }
    public static void main(String args[])
    {
    new JTextFieldExample();
    }
    
}

Related Articles:

COMMENTS

Name

android arrays cnna1 graphics java java control statements java.swing JButton JFrame JLabel JTextField laravel node.js OPP questions swing technology
false
ltr
item
Code WHIZZ: Enable and Disable JTextField using setEnabled(Boolean boolean) Method
Enable and Disable JTextField using setEnabled(Boolean boolean) Method
Code WHIZZ
https://code-whizz.blogspot.com/2017/05/enable-and-disable-jtextfield-using.html
https://code-whizz.blogspot.com/
http://code-whizz.blogspot.com/
http://code-whizz.blogspot.com/2017/05/enable-and-disable-jtextfield-using.html
true
5534598864497432585
UTF-8
Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy