Solved

Changing from Choice to JComboBox

Posted on 2004-10-22
184 Views
Last Modified: 2010-03-31
Hallo,
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();
          portChoice.addItemListener(this);
          add(portChoice);
          listPortChoices();
          portChoice.select(parameters.getPortName());

}

now i have to change my choice object to JComboBox object

do i have any methods in JComboBox as
(JComboBoxobject).select();

how can i access the items in the JComboBox.


With regards

Ashok.G

0
Question by:ashok3sep
    4 Comments
     
    LVL 37

    Expert Comment

    by:zzynx
    0
     
    LVL 37

    Accepted Solution

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

    Expert Comment

    by:zzynx
    >> how can i access the items in the JComboBox.
    Use  
            Object getItemAt(int index)
    0
     
    LVL 37

    Expert Comment

    by:zzynx
    Thanks for accepting
    0

    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