Java JComboBox loadPrefs(Preferences prefs, String prefKey, JComboBox combo)

Here you can find the source of loadPrefs(Preferences prefs, String prefKey, JComboBox combo)

Description

load Prefs

License

Open Source License

Declaration

public static void loadPrefs(Preferences prefs, String prefKey, JComboBox combo) 

Method Source Code

//package com.java2s;
/**********************************************************************************************
 *
 * Asprise OCR Java API/*w  w  w  . ja v  a  2  s  .  c  o m*/
 * Copyright (C) 1998-2015. Asprise Inc. <asprise.com>
 *
 * This file is licensed under the GNU Affero General Public License version 3 as published by
 * the Free Software Foundation.
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the
 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * You should have received a copy of the GNU Affero General Public License.  If not, please
 * visit <http://www.gnu.org/licenses/agpl-3.0.html>.
 *
 **********************************************************************************************/

import javax.swing.DefaultComboBoxModel;

import javax.swing.JComboBox;

import java.util.StringTokenizer;
import java.util.prefs.Preferences;

public class Main {
    static final String DELIMITER = "`";

    public static void loadPrefs(Preferences prefs, String prefKey, JComboBox combo) {

        DefaultComboBoxModel comboModel = new DefaultComboBoxModel();
        String recents = prefs.get(prefKey, null);
        if (recents != null) {
            StringTokenizer st = new StringTokenizer(recents, DELIMITER);
            while (st.hasMoreTokens()) {
                comboModel.addElement(st.nextToken());
            }
        }

        combo.setModel(comboModel);
    }
}

Related

  1. isEmptyStr(javax.swing.JComboBox input)
  2. isJComboBoxNotEmpty(javax.swing.JComboBox combo)
  3. largeThan(javax.swing.JComboBox input, double x)
  4. loadComboBox(JComboBox combo, List list)
  5. loadEnum(JComboBox combo, Class c, boolean removeAll)
  6. makeJComboBox(ResourceBundle resource, String panelName, String keyword)
  7. makeSquare(JComboBox... comboBoxes)
  8. newCombo(int chars)
  9. prepareComboBox(JComboBox comboBox, Dimension size, int min, int max, int[] list)