Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



What is the use of TextField class?

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 06-03-2010
Member
 
Join Date: Jan 2010
Posts: 70
What is the use of TextField class?
  

Hello Guys,

I have to discuss one of my java query with you. I want to be aware about the use of TextField class of the java programming language. I don't have sound knowledge about TextField class. I have referred lots of websites for this TextField class, but nothing was helpful. So if you posses good knowledge regarding TextField class of java then please let me aware about that.

Reply With Quote
  #2  
Old 06-03-2010
Member
 
Join Date: May 2008
Posts: 2,293
Re: What is the use of TextField class?

It is also possible to fire an ActionEvent. If action events are enabled for the text field, they may be fired by pressing the Return key. The TextField class's processEvent method examines the action event and passes it along to processActionEvent. The latter method redirects the event to any ActionListener objects that have registered to receive action events generated by this text field.
Reply With Quote
  #3  
Old 06-03-2010
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: What is the use of TextField class?

Hello friend,

I suggest you to study below example of TextField class, which will depict it's use:
Code:
java.awt.TextField
import javax.swing.JTextField;

public class TextFieldDM
 {
  public static void main(String[] argnns) {
    JTextField tf1 = new JTextField("mm");
    tf1.setPreferredSize(tf.getPreferredSize());
    tf1.setText("");

    JPanel pHacked1 = new JPanel();
    pHacked1.add(tf1);
    JPanel pStock1 = new JPanel();
    pStock1.add(new JTextField(2));
    JFrame frame1 = new JFrame();
    frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame1.setLayout(new java.awt.GridLayout(0, 1));
    frame1.add(pHacked1);
    frame1.add(pStock)1;
    frame1.setSize(100, 150);
    frame1.setVisible(true);
    tf1.requestFocus();
  }
}
Reply With Quote
  #4  
Old 06-03-2010
Member
 
Join Date: May 2008
Posts: 2,383
Re: What is the use of TextField class?

Hi,

There are total four constructors of TextField class. All the four constructor takes different number and type of input parameters. There is one constructor of TextField class is empty. See following constructors:
  • TextField(String txt, int coln)
  • TextField(String txt)
  • TextField(int coln)
  • TextField()
Reply With Quote
  #5  
Old 06-03-2010
Member
 
Join Date: Feb 2008
Posts: 1,848
Re: What is the use of TextField class?

Below I have mentioned the example of the TextField class, review it carefully:
Code:
import javax.swing.*;
java.awt.TextField;
import java.awt.*;

public class JTextFieldSample
{
  public JTextFieldSample() {
    super("JTextField Test");

    getContentPane().setLayout(new FlowLayout());

    JTextField textFieldJ = new JTextField("1", 1);
    JTextField textFieldk = new JTextField("22", 2);
    JTextField textFieldl = new JTextField("333", 3);

    getContentPane().add(textFieldJ);
    getContentPane().add(textFieldk);
    getContentPane().add(textFieldl);
    setSize(200, 170);
    setVisible(true);
  }

  public static void main(String argjv[]) {
    new JTextFieldSample();
  }
}
Reply With Quote
  #6  
Old 06-03-2010
Member
 
Join Date: Jan 2008
Posts: 1,515
Re: What is the use of TextField class?

Hi friend,

Please go through the following some important methods of TextField class:
  1. setEchoCharacter(char ch)
  2. setEchoChar(char ch)
  3. setColumns(int coln)
  4. removeActionListener(ActionListener lstn)
  5. processEvent(AWTEvent evnt)
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "What is the use of TextField class?"
Thread Thread Starter Forum Replies Last Post
Upgrade Sony Ericsson Xperia Play Micro SD card from class 2 8GB to class 4 32GB Aaryan2011 Portable Devices 8 08-10-2011 11:06 PM
Me.SelectAll is not working on Textfield Zakiy Software Development 5 27-07-2011 11:09 PM
Nokia 5800 Bug - Auto Rotation And Textfield Uday64 Software Development 4 21-04-2010 04:05 PM
Nokia 5800 Bug - Auto rotation and textfield Agriya Portable Devices 4 20-04-2010 09:39 AM
Good news for CBSE CLASS X & CLASS IX - visit learnnext surya_expert Education Career and Job Discussions 0 13-12-2008 12:09 PM


All times are GMT +5.5. The time now is 06:55 AM.