UsingJComboBox

40
rate or flag this page

By sepiroth

Using JComboBox
Using JComboBox

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:

Here's our output
Here's our output

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

Comments

RSS for comments on this Hub

No comments yet.

Submit a Comment

Members and Guests

Sign in or sign up and post using a hubpages account.


optional


  • No HTML is allowed in comments, but URLs will be hyperlinked
  • Comments are not for promoting your hubs or other sites

working