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:  




5 comments :

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

    ReplyDelete
  2. Thanks for the good words! Really appreciated. Great post. I’ve been commenting a lot on a few blogs recently, but I hadn’t thought about my approach until you brought it up. 
    python Training in Pune
    python Training in Chennai
    python Training in Bangalore

    ReplyDelete
  3. This looks absolutely perfect. All these tiny details are made with lot of background knowledge. I like it a lot. 
    Best Devops Training in pune
    Devops Training in Bangalore
    Power bi training in Chennai

    ReplyDelete
  4. Awesome! Education is the extreme motivation that open the new doors of data and material. So we always need to study around the things and the new part of educations with that we are not mindful.
    Data Science training in rajaji nagar
    Data Science with Python training in chennai
    Data Science training in electronic city
    Data Science training in USA
    Data science training in bangalore

    ReplyDelete

Copyright © Rough Record. Designed by OddThemes