dcsimg
www.webdeveloper.com
Results 1 to 1 of 1

Thread: Display Value in JcomboBox

  1. #1
    Join Date
    Sep 2005
    Posts
    38

    JcomboBox

    Hi,
    I have a JcomboBox. I want to display all the ItemId from the database in that JComboBox. I used Vector.but the records are not displaying in the jcombobox.It is printing the values in the console. I think the problem is with the line "itemno=new JComboBox(result);"
    I am getting the values from the selectItemID() method.but it is not assigning it to the jcombobox
    The code is:-

    public Vector selectItemID(){
    Vector result = new Vector();

    try {
    statement = dbConnection.prepareStatement("select ItemId from ItemDetails");
    ResultSet itemNumberResult = statement.executeQuery();
    while(itemNumberResult.next())
    {
    String itemNo = itemNumberResult.getString(1);
    System.out.println("itemNo " +itemNo);
    result.add(itemNo); // add all found itemNos
    }
    } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    return result;

    }


    DbActivity dbconnection = new DbActivity();

    Vector result= dbconnection.selectItemID();
    itemno=new JComboBox(result); // construct Combo with Vector
    //System.out.println("Result "+result);


    Regards
    Daina
    Last edited by daina; 09-28-2005 at 06:47 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles