Changing from Choice to JComboBox

Posted on 2004-10-22
Last Modified: 2010-03-31
I have a object for choice and i add the items to the choice object.

then i have a select method of choice to select the item in the choice box.

now i am changing to JComboBox instead of Choice

how can i select the item in the JComboBox.

here is a piece of my code:

public class choicedemo{
private Choice portChoice;

 portChoice = new Choice();


now i have to change my choice object to JComboBox object

do i have any methods in JComboBox as

how can i access the items in the JComboBox.

With regards


Question by:ashok3sep
    LVL 37

    Expert Comment

    LVL 37

    Accepted Solution

    >> how can i select the item in the JComboBox.
    You can use  
          setSelectedIndex(int anIndex)     // passing an index
          setSelectedItem(Object anObject) // passing an objec
    LVL 37

    Expert Comment

    >> how can i access the items in the JComboBox.
            Object getItemAt(int index)
    LVL 37

    Expert Comment

    Thanks for accepting

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
    This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

    846 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    6 Experts available now in Live!

    Get 1:1 Help Now