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
Oh never mind never mind I got it. For the actionPerformed method, you would then continue it with numerous if statements and say "if(animals.getSelectedIndex()==0 {sysout("German Sheppard")" i see now, i get it
Hey Bro! Question for you! How do you setSelectedItem(String_var_here) from another class calling the JcomboBox. It doesnt show the change on the GUI and the box is 'frozen'.
4:25 so what if you want the getSelectedItem to show different text that corresponds to each string on the GUI? So let's say I want to click dog and I want the sysout to say "German Sheppard", how you do that? Thanks for the reply and your free educational videos
@@AnthonyR007 so i did exactly that but now i have hundreds of if statements for every single dog breed and it looks totally all unprofessional and not "programmer like". I'm trying to make an array of dog breeds and just writing one if statements with the array number in the parameters
@@AnthonyR007 i can't quite get it to work because I'm not trained or a professional so i guess I'll just continue writing hundreds of if statements like a noob lol
Yes, in this video he used a border layout ( If you don't set a layout for a JFrame, it will use a BorderLayout by default ) Also it works for null layout but don't forget to set the bounds and pack the frame.
Hi, guys. Can someone help me with one situation I noticed? When I use the setEditable method and type one item that isn't the first one it executes the action performed method twice. This doesn't happen when I type in the comboBox the first Item. I'm goin' to let the code here in case anyone knows what is wrong here, and how can I make it work better.
Yo just wanna say that GOD loved the world so much he sent his only begotten son Jesus to die a brutal death for us so that we can have eternal life and we can all accept this amazing gift this by simply believing in him (Jesus) asking for the forgiveness of your sins and forming a relationship with heavenly father.
Practicing... public class Main{ public static void main(String[]args){ new MyFrame(); } } ***************************** import java.awt.*; import java.awt.event.*; import javax.swing.*; public class MyFrame extends JFrame implements ActionListener{ JComboBox comboBox;
//***********************************************
public class Main{
public static void main(String[] args) {
// JComboBox = A component that combines a button or editable field and a drop-down list
new MyFrame();
}
}
//***********************************************
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MyFrame extends JFrame implements ActionListener{
JComboBox comboBox;
MyFrame(){
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new FlowLayout());
String[] animals = {"dog","cat","bird"};
comboBox = new JComboBox(animals);
comboBox.addActionListener(this);
//comboBox.setEditable(true);
//System.out.println(comboBox.getItemCount());
//comboBox.addItem("horse");
//comboBox.insertItemAt("pig", 0);
//comboBox.setSelectedIndex(0);
//comboBox.removeItem("cat");
//comboBox.removeItemAt(0);
//comboBox.removeAllItems();
this.add(comboBox);
this.pack();
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==comboBox) {
System.out.println(comboBox.getSelectedItem());
//System.out.println(comboBox.getSelectedIndex());
}
}
}
Hey Bro, I'm from Brazil and I want to thank you for all your videos about java. I have been learning a lot with BroCode channel. Thank you!
Danke schon bruder. Your explanation was straight to the point and clear. Also thanks for the code.
420th like 😎
your videos really help bro! Thank you!
Doing my Part to defeat the Algorithm.
Keep it up mate!!!
Very clean explanation. It was really helpful for me, thanks ✓
thank you for watching Kaymak!
I love your gui vidios they are so helpful
thank you Nono!
i have become a good developer in java because your video are extra ordinaire, very claire:
thantyou bro, God bless you a lot
coooooool , best tutorials ever , good job bro code
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
Thank you for all your work
Subscribed. Please do more tut of Gui in java
thanks bro! I will
you saved my day tnx
Thank you very much for this video
very clear!
this is what I call quality content
You are the best!! :)
please do tutorial of jdbc also and make a project using Java Swing and JDBC
Great
Thanks brother 😊
Great video, thanks
This was verry helpfull
Very good.
ty
Thanks bro
thank you for the content
Nice, bro!
Thanks
Good video
Love this.
Thank you very much for sharing this video, easy to understand.
Thanks that was helpful 👍
NIce video
thanks bro
thx
Ur the best
gooood job
keep it on
Da best
combobox. yeah
hi, have a great Sunday
how much do you program every day?
I mostly code exclusively for these videos almost daily, but I do have other projects I work on occasionally
Oh never mind never mind I got it. For the actionPerformed method, you would then continue it with numerous if statements and say "if(animals.getSelectedIndex()==0 {sysout("German Sheppard")" i see now, i get it
You should’ve replied this to your original comment lol
Hey Bro! Question for you!
How do you setSelectedItem(String_var_here) from another class calling the JcomboBox. It doesnt show the change on the GUI and the box is 'frozen'.
How to store user’s selection in a variable
how can I sort alphabetically items inside a combobox ? Thanks
wombo combo
Can i change the color of scroll? How?
hello
4:25 so what if you want the getSelectedItem to show different text that corresponds to each string on the GUI? So let's say I want to click dog and I want the sysout to say "German Sheppard", how you do that?
Thanks for the reply and your free educational videos
If statement, in the action listener, if the text is dog, output German shepard
@@AnthonyR007 so i did exactly that but now i have hundreds of if statements for every single dog breed and it looks totally all unprofessional and not "programmer like". I'm trying to make an array of dog breeds and just writing one if statements with the array number in the parameters
@@AnthonyR007 i can't quite get it to work because I'm not trained or a professional so i guess I'll just continue writing hundreds of if statements like a noob lol
@@jaybartgis5148 you could use a switch case statement with the indexes?
It’ll still be a lot of code, but it will be less resource intensive
Can I add a JComboBox on a JFrame with null Layout or a BorderLayout?
Yes, in this video he used a border layout ( If you don't set a layout for a JFrame, it will use a BorderLayout by default )
Also it works for null layout but don't forget to set the bounds and pack the frame.
Oh. So this isn’t minecraft
Hi, guys. Can someone help me with one situation I noticed? When I use the setEditable method and type one item that isn't the first one it executes the action performed method twice. This doesn't happen when I type in the comboBox the first Item.
I'm goin' to let the code here in case anyone knows what is wrong here, and how can I make it work better.
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JComboBox;
import javax.swing.JFrame;
public class Main {
public static void main (String [] args) {
new MyFrame();
}
}
class MyFrame extends JFrame implements ActionListener {
JComboBox comboBox;
MyFrame() {
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new FlowLayout());
String [] animals = {"dog","cat","bird"};
comboBox = new JComboBox(animals);
comboBox.addActionListener(this);
comboBox.setEditable(true);
this.add(comboBox);
this.pack();
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == comboBox) {
System.out.println(comboBox.getSelectedItem());
System.out.println(comboBox.getSelectedIndex());
}
}
}
Hey.
Comment
🐽🐕🐈
Yo just wanna say that GOD loved the world so much he sent his only begotten
son Jesus to die a brutal death for us so that we can have eternal life
and we can all accept this amazing gift this by simply believing in him (Jesus) asking for the forgiveness of your sins
and forming a relationship with heavenly father.
Practicing...
public class Main{
public static void main(String[]args){
new MyFrame();
}
}
*****************************
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MyFrame extends JFrame implements ActionListener{
JComboBox comboBox;
MyFrame(){
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLayout(new FlowLayout());
String[]destinations = {"Zanzibar","Solomon Islands", "Saint Lucia"};
//Integer[]destinations = {1,2,3};
comboBox = new JComboBox();
comboBox.addActionListener(this);
//comboBox.setEditable(true);
//System.out.println(comboBox.getItemCount());
//comboBox.add("Senegal");
//comboBox.insertItemAt("Turks and Caicos Islands",3);
//comboBox.setSelectedIndex(3);
//comboBox.removeItem("Saint Lucia");
//comboBox.removeItemAt(0);
comboBox.removeAllItems();
this.add(comboBox);
this.pack();
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e){
if(e.getSource()==comboBox){
//System.out.println(comboBox.getSelectedItem());
System.out.println(comboBox.getSelectedIndex());
}
}
}
Thanks