Java JComboBox Selection setSelectedHeadersaveFileTypeItem( JComboBox combo, int fileType)

Here you can find the source of setSelectedHeadersaveFileTypeItem( JComboBox combo, int fileType)

Description

set Selected Headersave File Type Item

License

Open Source License

Declaration

public static boolean setSelectedHeadersaveFileTypeItem(
            JComboBox combo, int fileType) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.JComboBox;

public class Main {
    public static String[] headersaveFileTypeItems = { "",
            "A - Assemblerquelltext", "B - BASIC-Programm",
            "b - Tiny-BASIC-Programm", "C - MC-Programm, selbststartend",
            "M - MC-Programm", "E - EPROM-Inhalt",
            "I - Information (Text)", "T - Text" };

    public static boolean setSelectedHeadersaveFileTypeItem(
            JComboBox combo, int fileType) {
        boolean rv = false;
        for (String s : headersaveFileTypeItems) {
            if (!s.isEmpty()) {
                if (s.charAt(0) == fileType) {
                    combo.setSelectedItem(s);
                    rv = true;/*  w ww  . j a  v  a 2  s  .  c om*/
                    break;
                }
            }
        }
        return rv;
    }
}

Related

  1. selectStringInList(String string, JComboBox list)
  2. selectWithoutNotifyingListeners(JComboBox comboBox, int selectedIndex)
  3. setComboSelection(JComboBox cb, String sel)
  4. setComboxSelectItem(JComboBox cb, String s)
  5. setListData(final JComboBox box, final Collection items, final E selected)
  6. updateContents( @SuppressWarnings("rawtypes") JComboBox box, Object[] options, int selectedIndex)