Source Code : EditabilityExample

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

EditabilityExample

EditabilityExample
    

/*
Core SWING Advanced Programming 
By Kim Topley
ISBN: 0 13 083292 8       
Publisher: Prentice Hall  
*/

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.Timer;
import javax.swing.UIManager;

public class EditabilityExample {
  public static void main(String[] args) {
    try {
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception evt) {}
  
    JFrame f = new JFrame("Editability Example");
    f.getContentPane().setLayout(
        new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS));
    f.getContentPane().add(firstField);

    JTextField tf = new JTextField("A read-only text field", 20);
    tf.setEditable(false);
    f.getContentPane().add(tf);

    JTextArea ta = new JTextArea("An editable
text area", 2, 20);
    ta.setBorder(BorderFactory.createLoweredBevelBorder());
    f.getContentPane().add(ta);

    ta = new JTextArea("A read-only
text area", 2, 20);
    ta.setBorder(BorderFactory.createLoweredBevelBorder());
    ta.setEditable(false);
    f.getContentPane().add(ta);

    f.pack();
    f.show();

    if (args.length == 1 && args[0].equals("disable")) {
      // Toggle the enabled state of the first
      // text field every 10 seconds
      Timer t = new Timer(10000, new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
          firstField.setEnabled(!firstField.isEnabled());
          firstField.setText(firstFieldText
              + (firstField.isEnabled() ? "" : " (disabled)"));
        }
      });
      t.start();
    }
  }

  final static String firstFieldText = "An editable text field";

  final static JTextField firstField = new JTextField(firstFieldText, 20);

}

           
         
    
    
    
  

Thank with us