UsingJComboBox
40
Here's a tutorials on how to use a JComboBox. Basically you should know about JAVA GUI and basic codings on usign awt components. If "No" you should search it on www.google.com my bestfriend in searching, lolz...
In this tutorial, this explains on how you use it only. We dont have an itemEvent yet... This is simply basic only.
Now, let's proceed. I have already made a basic codes that we will use on in making JAVA GUI.
here it is:
SampleJComboBox.java
import java.awt.*;
import javax.swing.*;
public class SampleJComboBox extends JFrame{
JComboBox cboCourse = new JComboBox(); //declaring a JComboBox
public SampleJComboBox(){
setTitle("Sample JCombo"); //setting the title
setSize(280,280); //setting the size
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //setting the default close
setVisible(true); //set visible
setLayout(new FlowLayout()); //setting the layout
cboCourse.addItem("BSIT"); //adding item on JCombo
cboCourse.addItem("ACT");
cboCourse.addItem("HRS");
cboCourse.addItem("DIT");
cboCourse.addItem("DCET");
Container ca = getContentPane(); //getting the content pane
ca.add(cboCourse); //adding cboCourse to your container
setContentPane(ca);
}
public static void main (String[] args){
new SampleJComboBox();
}
}
Just follow the codes...
Here's a video tutorials on how do I code it. I advise that you maximize the video when you watch some of the text is blurred. I hope this will help.
Thanks..
Video on how to apply JComboBox
PrintShare it! — Rate it: up down flag this hub







