Java textfield 📛

Поділитися
Вставка
  • Опубліковано 19 вер 2024
  • Java, textfield, JTextField, GUI, swing, tutorial, beginners,
    #Java #textfield #JTextField #GUI #swing #tutorial #beginners
    Coding boot camps hate him! See how you can teach you to code with this one weird trick...
    Drop a comment down below and subscribe if you'd like to become a fellow bro.
    This is a tutorial channel for beginners to learn how to code.
    A few languages I plan on covering include, but are not limited to:
    Python
    Java
    C#
    C++
    C
    Javascript
    HTML
    CSS
    Django
    MySQL
    and more probably...maybe
    ¯\_(ツ)_/¯

КОМЕНТАРІ • 63

  • @BroCodez
    @BroCodez  4 роки тому +44

    // *********************************************************
    public class Main{
    public static void main(String[] args) {

    // JTextField = A GUI textbox component that can be used to add, set, or get text
    new MyFrame();
    }
    }
    // *********************************************************
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.Font;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JTextField;
    public class MyFrame extends JFrame implements ActionListener{
    JButton button;
    JTextField textField;

    MyFrame(){
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setLayout(new FlowLayout());

    button = new JButton("Submit");
    button.addActionListener(this);

    textField = new JTextField();
    textField.setPreferredSize(new Dimension(250,40));
    textField.setFont(new Font("Consolas",Font.PLAIN,35));
    textField.setForeground(new Color(0x00FF00));
    textField.setBackground(Color.black);
    textField.setCaretColor(Color.white);
    textField.setText("username");


    this.add(button);
    this.add(textField);
    this.pack();
    this.setVisible(true);
    }
    @Override
    public void actionPerformed(ActionEvent e) {
    if(e.getSource()==button) {
    System.out.println("Welcome "+ textField.getText());
    //button.setEnabled(false);
    //textField.setEditable(false);
    }

    }
    }
    // *********************************************************

  • @carlosarruda4029
    @carlosarruda4029 Рік тому +1

    I'm surprised, because I learning Java and you channel is the one of bests in UA-cam, tank you so much for this! I'm Brazilian and love your videos bro!!

  • @pavelkvasnicka6856
    @pavelkvasnicka6856 Рік тому +2

    This is the best Java tutorial for beginners, so you can learn Java and English in one hit. Please keep going! I vote for Java advance tutorial. Thanks a lot Bro

  • @justinknew1554
    @justinknew1554 4 роки тому +15

    I've been watching this series and honestly im surprised these videos dont have more likes. you do a good job at explaining this stuff and making it easy to understand. im having a problem where setting the text of the textfield is making everything disappear and i cant figure out why. heres my code for the textfield
    package notHomework;
    import java.awt.Dimension;
    import java.awt.Font;
    import javax.swing.JTextField;
    public class TextFieldList extends JTextField {
    TextFieldList(int width, int height, String[] notes) {
    this.setPreferredSize(new Dimension(width, height));
    String text = "";

    for(int i = 0; i < notes.length; i++) {
    text = text + notes[i] + "
    ";
    }
    System.out.println(text);
    this.setText(text);
    }
    }

    • @justinknew1554
      @justinknew1554 4 роки тому +3

      nevermind xD i forgot to pack

    • @BroCodez
      @BroCodez  4 роки тому +4

      haha that is an easy thing to forget to do

  • @abdumalikumarov4085
    @abdumalikumarov4085 3 роки тому +2

    Bro, thank you, ur videos r the best I have ever seen, Good luck, I will inform all my friends about your channel

  • @m.uzairsadiq695
    @m.uzairsadiq695 6 місяців тому

    Hi Bro! I am a CS student and you have been the best teacher.THANK YOU! You are AWESOME!

  • @brianheeley
    @brianheeley 3 роки тому

    I've watched so many of your videos and they have all helped me out so much!! Thank you

  • @bassantahmed2632
    @bassantahmed2632 3 роки тому +1

    THANK YOU THAT WAS WAY MORE BENEFICIAL AND I DO ADMIRE YOUR WAY OF TEACHING♥

  • @easytogit4682
    @easytogit4682 4 роки тому

    Good stuff! This was super helpful & well explained 👍. Your the best 😊

  • @eugenezuev7349
    @eugenezuev7349 4 місяці тому

    love your lessons

  • @winterSweet-k4m
    @winterSweet-k4m 4 роки тому +16

    just saying, I was here before 10K, 25K, 50K, 100K, 500K and 1M!

  • @honoredegg
    @honoredegg 2 роки тому +1

    59th. Thank you, ma Bro Sensei

  • @stefanmilinkovic6433
    @stefanmilinkovic6433 Рік тому +1

    Can you do a video for how to validate user name and age ? Like they can only have alphabet and valid characters, and age can only be digits 0-100 years okd

  • @arthur-monteath
    @arthur-monteath Рік тому

    Nice video!

  • @MmdRsh
    @MmdRsh Рік тому

    man u are real hero

  • @birandai5993
    @birandai5993 2 роки тому

    Subscribed and liked Mr.Bro Code! If you could upload some ideas about the Mini-project at University level. For pre-testing, we have bus reservation project. So if you would help me out about this.

  • @travel_to_wonders6666
    @travel_to_wonders6666 2 роки тому

    Just love your video😍😍😍

  • @DrinkableWater
    @DrinkableWater 4 роки тому

    Nice and Easy to understand Video :D Thank you

    • @BroCodez
      @BroCodez  4 роки тому +1

      thanks for watching!

  • @roxstrcreation1711
    @roxstrcreation1711 2 роки тому

    Best Channel till date

  • @majid1885
    @majid1885 2 роки тому

    Awesome as always, Thank you Bro

  • @speklex779
    @speklex779 10 місяців тому

    Nice video

  • @user-nk8fd4hn4v
    @user-nk8fd4hn4v 2 роки тому

    Thank you 🙏, this video is very helpful

  • @cedricpulmano9234
    @cedricpulmano9234 2 роки тому

    You are so useful, absolute alpha chad bro

  • @kemann3815
    @kemann3815 2 роки тому

    Absolutely brilliant 👏

  • @НікітаОрлов-с3ч

    Hi bro, thanks for lesson

  • @angelcastineira2561
    @angelcastineira2561 Рік тому

    great videos!

  • @ajaykumar_tamilan
    @ajaykumar_tamilan Рік тому

    nice video thank you bro

  • @tientungnguyen5283
    @tientungnguyen5283 2 роки тому

    it helped me a lots, thanks

  • @xingtingpeng5817
    @xingtingpeng5817 2 роки тому

    YOU ARE MY HERO!!! THANK YOU!!!!!!!!!

  • @akshaykumarsharma
    @akshaykumarsharma 3 роки тому +1

    What is the difference between setSize and setPrefferedSize methods

    • @BroCodez
      @BroCodez  3 роки тому +1

      setSize() -is mostly used when there is no layout manager
      setPreferredSize() - is mostly used when there is a layout manager

  • @superTramp572
    @superTramp572 Рік тому

    Thank you thank you thank you, guys say thank you to get this awsome channel more views. Because...this is what Bros do🤜

  • @bwsoul9770
    @bwsoul9770 3 роки тому

    bro i got a problem i can't set a text in the textfield for some reason idk why here is that part of the code
    public class two extends JPanel implements ActionListener {
    JButton btn1;
    three puts ;
    two(){
    this. setPreferredSize(new Dimension(400,250));
    this.setLayout(new GridLayout(5,5,5,5));
    this.setBackground(Color.LIGHT_GRAY);
    puts = new three();
    this.add(btn1 = new JButton("MOD"));
    btn1.addActionListener(this);
    btn1.setFont(new Font("MV Bolis",Font.ITALIC,13));
    }
    @Override
    public void actionPerformed(ActionEvent e) {
    if(e.getSource()==btn1){puts.txtfld.setText("MOD");}
    ////puts is the object of the class named three extending JPanel and txtfld is the textfield in it cuz the button and the textfield are in different classes

  • @aymen_abush22
    @aymen_abush22 Рік тому

    Hi! how are you
    I want a way to hide the text that is in a text field, if possible

  • @asgharwasim9949
    @asgharwasim9949 Рік тому

    Hello sir. i need help to make JTextfield as auto suggestion box. i need a component for making jtextfield as autocomplete/autosuggestion. Thanks

  • @developerjunior446
    @developerjunior446 3 роки тому

    Simple Amazing

  • @henriquefelinimena3693
    @henriquefelinimena3693 3 роки тому

    thank you for the content

  • @MrLoser-ks2xn
    @MrLoser-ks2xn 2 роки тому

    Thanks

  • @antoinealam6531
    @antoinealam6531 2 дні тому

    C mon bro, mercii

  • @HappyYourSelf
    @HappyYourSelf 3 роки тому

    Hi sir,i can't type uicode in textfield. How to me type unicode in textfield javafx. Please

  • @stelioskapsis6993
    @stelioskapsis6993 3 роки тому

    how can i have my text appear in my frame and not the console while also using the scanf function?

  • @yulvarnal
    @yulvarnal Рік тому

    what if i want to put a intgers in the text box

  • @MasoudAshraqzada
    @MasoudAshraqzada Місяць тому

    ❤❤❤

  • @pinkflower03
    @pinkflower03 2 роки тому +1

    Anyone knows how to emboss TextField in awt ? I'm new

  • @Amangupta-rh7cy
    @Amangupta-rh7cy 3 роки тому

    Good video

  • @minari3462
    @minari3462 Рік тому

    what if theres 2 buttons?

  • @ibrahimylmaz8378
    @ibrahimylmaz8378 2 роки тому

    thanks bro

  • @ankurrPurohit
    @ankurrPurohit 2 роки тому

    Best

  • @deepdaddy1208
    @deepdaddy1208 4 роки тому +1

    Brooooo

  • @SashaL_music
    @SashaL_music Рік тому

    Does anyone know how to do this in a single java file ?

  • @mohanapavanbezawada4322
    @mohanapavanbezawada4322 4 місяці тому

    YO bro

  • @greeneggsandmushrooms9855
    @greeneggsandmushrooms9855 3 роки тому

    buttonfields

  • @zari_723
    @zari_723 2 роки тому

    hi everyone

  • @HappyYourSelf
    @HappyYourSelf 3 роки тому

    Hi sir,i can't type uicode in textfield. How to me type unicode in textfield javafx. Please

  • @PoorwayTraning
    @PoorwayTraning Рік тому

    thanks

  • @nawfalnjm5699
    @nawfalnjm5699 3 роки тому

    thanks