Code:
import java.awt.FlowLayout;
 
import javax.swing.JApplet;
import javax.swing.JTextField;
 

public class ColEx extends JApplet{
 
        public void init(){
               
               
                this.getContentPane().setLayout(new FlowLayout());
               
               
                JTextField field123 = new JTextField("Columns Example");
               
                
               
                field123.setColumns(20);
              
                int col = field123.getColumns();
               
                add(field123);
               
        }
}