A JComboBox is a scrollable list of options or labels in a Java graphical user interface, or GUI, program. You cannot edit text in this box; however, you can select multiple items from the list of options. Each item in a JComboBox is defined within the Java code, and additional items can be pushed into the box with a single line addition. These combination boxes are applied in many different programs, such as when selecting a set of interests or the days of the week when an alarm should ring.
Open your Java application in your preferred text editor or Java development environment.
Locate your JComboBox within the program. All JComboBox items are created with the "New JComboBox" syntax, so you can use your program's "Search" feature to scan the document for all occurrences of the word "JComboBox."
Add the new item to the JComboBox on a new line using the "addItem()" function of the JComboBox. This command must be issued after the JComboBox is created. For example, to add the text "Banana" and "Elephant" to a JComboBox named "combo1," you would enter the following code:
JComboBox combo1 = new JComboBox();
How to Add a ComboBox to a Form in a Swing
The SWING is a Java Foundation Classes software kit that provides graphical user interface to Java programs. It allows users to display...
How to Select Multiple Items on a Computer
Being able to select multiple computer files eases the process of copying and pasting large numbers of files at once. Depending on...
How to Scan an Item to PowerPoint
A scanning device is used to transfer contents from paper into an image your computer can read. When you scan content into...
How to Add Items to a Dropdown/ComboBox in VB.net
In Visual Basic, a ComboBox -- also known as a drop-down menu -- contains a list of items, and it allows the...
Java BorderLayout Tutorial
In Java's Swing GUI library (as well its precursor AWT), the arrangement of components within a frame or panel is determined by...
How to Add Text to a PDF File
PDF files are a great way for anyone with a PDF reading program to view files from software applications they might not...
How to Find a Substring in Java
In Java, a string is an array of characters (letters, numbers or symbols). A substring of a string is simply a collection...
How to Query to Find an Item in Multiple Fields in Access
Microsoft Access is the database system software program included in the Microsoft Office suite. Its primary function is to allow the user...