25 April 2012

Create a textBox using jframe


Here Iam creating a jframe with some set properties like setsize, setlocations.

Here two textboxes are here one for entering input and another for printing output. after entering just press on get value button it will display the values in in textbox input to textbox output.



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

import javax.swing.JButton;
import javax.swing.JFrame;

import javax.swing.JTextField;


public class CreateTextbox extends JFrame implements ActionListener{
     
      JTextField input,output;
      JButton print;
     
     
      public CreateTextbox(){
           
            setLayout(null);
                input = new JTextField(5);
                input.setBounds(100,20,100,20);
              add(input);
             
              output = new JTextField(5);
              output.setBounds(180,200,100,20);
              add(output);
             
              print = new JButton("Get Value");
              print.setBounds(20,200,100,20);
              print.addActionListener(this);
              add(print);
           
      }
     
      public void actionPerformed(ActionEvent e) {
             if(e.getSource()== print )
             {
                   output.setText(input.getText());
             }
      }
     
      public static void main (String[] args)
    {
            CreateTextbox me = new CreateTextbox();
         me.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         me.setVisible(true);
         me.setLocation(550, 500);
         me.setSize(300, 300);
         me. setTitle("Create Textbox");

    }

}



output:  




3 comments:

Rajkumar said...

great faizal keep it up fine good excellent jog ......................................................................................................................................................

for IT the said...

I have read your blog its very attractive and impressive. I like it your blog.

Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

Java Online Training Java Online Training Core Java 8 Training in Chennai Core java 8 online training JavaEE Training in Chennai Java EE Training in Chennai

Naviya Nair said...

I have read your blog its very attractive and impressive. I like it your blog.

Java Online Training Java EE Online Training Java EE Online Training Java 8 online training Core Java 8 online training

Java Online Training from India Java Online Training from India Core Java Training Online Core Java Training Online Java Training InstitutesJava Training Institutes

Post a Comment

Related Posts with Thumbnails

Popular Posts

 
;