assigning arraylist to combo box

Ads
 

assigning arraylist to combo box

Hi

I am busy coding the Airline Reservation program, i have an arraylist of locations which i want to assing to the combo box. please help.

View Answers

June 4, 2013 at 7:15 PM

hi friend,

Try the following code may this will be helpful for you.

package net.roseindia.swingExample;

import javax.swing.*;

import java.awt.BorderLayout;
import java.util.*;
public class DisplayArraylistElementInCombobox {

    JFrame frame;   
    public void createUI()
    {
        frame = new JFrame("Combobox Example");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLayout(new BorderLayout());
        JComboBox combo = new JComboBox();      
        ArrayList list = new ArrayList();   
        list.add("Delhi");
        list.add("Mumbai");
        list.add("Chennai");
        list.add("Kolkata");
        Iterator itr = list.iterator();
        while(itr.hasNext())
        {
            combo.addItem(itr.next());
        }
        JPanel panel = new JPanel();
        combo.setBounds(100, 100, 150, 20);             
        panel.add(combo);
        frame.add(panel);
        frame.setVisible(true);
        frame.setSize(300, 200);
    }
    public static void main(String args[])
    {
        DisplayArraylistElementInCombobox display = new DisplayArraylistElementInCombobox();
        display.createUI();
    }

}

Thanks.

Ads









Related Tutorials/Questions & Answers:
assigning arraylist to combo box
assigning arraylist to combo box  Hi I am busy coding the Airline Reservation program, i have an arraylist of locations which i want to assing to the combo box. please help
combo box
combo box  Hi, [_|] dropdown box [ ] [INCLUDE... a screen like this using jsp-servlet(or DAO,DTO),in that drop down box i should get
Advertisements
populate Combo Box dynamically
populate Combo Box dynamically  Hi, How to populate the Combo Box dynamically using Flex with Jsp's
date in combo box
date in combo box  strong texthello, how can i desplay the current year and next year in combo box???!!! it must be uppdate atumaticaly every year>>>
combo box connection
combo box connection  how to provide connection between three combo boxes,if my 1st combo box is course and 2nd combo box is semester and 3rd combo box is my subjects.what's the coding to provide the connection between this three
Problem With Combo Box Editable Property
Problem With Combo Box Editable Property  Hi I am new To Flex i had set Combo Box Editable Property as true. But I didn't get the property filtering in the combo box like when you enter text "S" in the combo box then the names
combo box value
combo box value   i want to populate one combo box value based on another combo box value using ajax   1)country.jsp: <%@page import="java.sql.*"%> <html> <head> <script language
combo box value
combo box value   i want to populate one combo box value based on another combo box value using ajax   1)country.jsp: <%@page import="java.sql.*"%> <html> <head>
Loading combo box from oracle
Loading combo box from oracle  how can i load values into a combobox from oracle database when a value is selected in another combo box
Helps with combo box and frame
Helps with combo box and frame  Hi i have a combobox and when i click... on the second window and click confirm i would have the information on the combo box. i... combo; JTextField txtBox; private String PersonViewing; private String
java combo box
java combo box  how to display messagedialogbox when the combobox is null, Thanks in advance
combo box code problem
combo box code problem  in this my problem related to : when i select state MP then i wil open the its corresponding city but in database it only stores the option value no like MP at option value 10 then it will stores the 10
how to create a combo box in html
how to create a combo box in html  <tr> <td>Number<span class=mandatory>*</span></td> <td> <select name="number" id="course" style="width:158px;"> <option value="none">----Select
Retrieving Data from Database to fill Combo Box
Page with a combo box and a label. I have a database that has two fields id and an image. Now I want to fill the combo box with image and on selecting a particular image in combo box it should be displayed on the label. My combo box is only
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records of worker i.e worker name. on a test.jsp and dispayed it into combo box ...my... of worker name within d combo box and display that id into a text box. plz answer
JavaScript Combo Box Validation
JavaScript Combo Box Validation       This application illustrates how to validate the combo box using JavaScript validation. In this example we create a combo box of different
Populate a combo box using data from a database
Populate a combo box using data from a database  Hi Guys, In need... combo box which will then load the next combo box values, now i know how... to the client using ajax, and then populate the combo box, I must'nt reload
how can retrive value from combo box in servlet?
how can retrive value from combo box in servlet?  i have a jsp page with combobox. And i want to get value from combox to servlet
retrieve the data to text fields from database on clicking the value of combo box
retrieve the data to text fields from database on clicking the value of combo box   retrieve the data to text fields from database on clicking the value of combo box . I am not getting it plz help me out .   hi
Retrieving data from data base using jsp combo box
Retrieving data from data base using jsp combo box  Hi guys please help me , i have on GUI page int that Server type(like apache,jboss,weblogic) one combo box is there and another filed is version of the server(like 1.0,2.0) like
How to get the values from the Combo Box - JSP-Servlet
, Actually i am getting the values in the combo box from table.I want what ever the value i select in combo box its corresponding records will display in their respective text box. e.g suppose i select ram values from the combo box and its
How to pass the value of Selected Value of combo box into sql ??
How to pass the value of Selected Value of combo box into sql ??  My SQL Database Name is MHS, user=root, password=admin,table name is sub_comb(regno,sname,sgen). Now i want to select one "regno" from Combobox and then after
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  Hi Friends...... For Example, in Student.jsp... when i click student id in combo box... in combo box from database.. by using select*from studentinformation; But when i
my table should be reseted to new value upon the selection of the combo box..
my table should be reseted to new value upon the selection of the combo box..  import java.awt.Container; import java.awt.FlowLayout; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.sql.Connection
How to show autocomplete textbox values on combo box option selection using database?
How to show autocomplete textbox values on combo box option selection using database?  When I select option(i.e First Year) then it will show list of student names in auto-complete text box
retrieving from oracle database using jsp combo box
retrieving from oracle database using jsp combo box  hi this is my code in this once i select the server type and version of the server the process name of the server has to display in the process name field from the oracle
Not Able to select an Item in Spark Combo Box control (Adobe Flex Object) using QTP
Not Able to select an Item in Spark Combo Box control (Adobe Flex Object) using QTP  Hi, I am trying to Automate a website developed using Adobe Flex controls. But i am not able to select any item from Spark Combo Box. I tied

Ads