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
¯\_(ツ)_/¯
// *********************************************************
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);
}
}
}
// *********************************************************
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!!
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
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);
}
}
nevermind xD i forgot to pack
haha that is an easy thing to forget to do
Bro, thank you, ur videos r the best I have ever seen, Good luck, I will inform all my friends about your channel
Hi Bro! I am a CS student and you have been the best teacher.THANK YOU! You are AWESOME!
I've watched so many of your videos and they have all helped me out so much!! Thank you
THANK YOU THAT WAS WAY MORE BENEFICIAL AND I DO ADMIRE YOUR WAY OF TEACHING♥
Good stuff! This was super helpful & well explained 👍. Your the best 😊
thanks bro!
love your lessons
just saying, I was here before 10K, 25K, 50K, 100K, 500K and 1M!
meee too! This channel is so underrated
59th. Thank you, ma Bro Sensei
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
Nice video!
man u are real hero
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.
Just love your video😍😍😍
Nice and Easy to understand Video :D Thank you
thanks for watching!
Best Channel till date
Awesome as always, Thank you Bro
Nice video
Thank you 🙏, this video is very helpful
You are so useful, absolute alpha chad bro
Absolutely brilliant 👏
Hi bro, thanks for lesson
great videos!
nice video thank you bro
it helped me a lots, thanks
YOU ARE MY HERO!!! THANK YOU!!!!!!!!!
What is the difference between setSize and setPrefferedSize methods
setSize() -is mostly used when there is no layout manager
setPreferredSize() - is mostly used when there is a layout manager
Thank you thank you thank you, guys say thank you to get this awsome channel more views. Because...this is what Bros do🤜
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
Hi! how are you
I want a way to hide the text that is in a text field, if possible
Hello sir. i need help to make JTextfield as auto suggestion box. i need a component for making jtextfield as autocomplete/autosuggestion. Thanks
Simple Amazing
thank you for the content
Thanks
C mon bro, mercii
Hi sir,i can't type uicode in textfield. How to me type unicode in textfield javafx. Please
how can i have my text appear in my frame and not the console while also using the scanf function?
what if i want to put a intgers in the text box
❤❤❤
Anyone knows how to emboss TextField in awt ? I'm new
Good video
what if theres 2 buttons?
thanks bro
Best
Brooooo
broooooooooo
Does anyone know how to do this in a single java file ?
YO bro
buttonfields
hi everyone
Hi sir,i can't type uicode in textfield. How to me type unicode in textfield javafx. Please
thanks
thanks