Java JComboBox addToComboBox(JComboBox list, Object object)

Here you can find the source of addToComboBox(JComboBox list, Object object)

Description

add To Combo Box

License

LGPL

Declaration

public static void addToComboBox(JComboBox list, Object object) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import javax.swing.*;

public class Main {
    public static void addToComboBox(JComboBox list, Object object) {
        ComboBoxModel model = list.getModel();
        if (model == null) {
            model = new DefaultComboBoxModel();
            list.setModel(model);/*from   w w w . j a va 2s. c  o m*/
        }
        ;
        if (model instanceof DefaultComboBoxModel) {
            DefaultComboBoxModel listModel = (DefaultComboBoxModel) model;
            listModel.addElement(object);
        }
    }
}

Related

  1. addHorizontalScrollBar(JComboBox box)
  2. addToCombo(JComboBox combo, Iterator it)
  3. adjustComboBoxHeight(JComboBox comboBox)
  4. adjustPopupWidth(JComboBox comboBox)
  5. adjustSize(JComboBox comboBox)
  6. applyDefaultProperties(final JComboBox comp)