Package org.intellij.sonar.util

Source Code of org.intellij.sonar.util.UIUtil

package org.intellij.sonar.util;

import com.google.common.base.Optional;

import javax.swing.*;

public final class UIUtil {

  private UIUtil() {}

  public static Object makeObj(final String item) {
    return new Object() {
      public String toString() {
        return item;
      }
    };
  }

  public static void selectComboBoxItem(JComboBox jComboBox, String name) {
    Optional itemToSelect = Optional.absent();
    for (int i = 0; i < jComboBox.getItemCount(); i++) {
      final Object item = jComboBox.getItemAt(i);
      if (name.equals(item.toString())) {
        itemToSelect = Optional.of(item);
      }
    }
    if (itemToSelect.isPresent()) jComboBox.setSelectedItem(itemToSelect.get());
  }
}
TOP

Related Classes of org.intellij.sonar.util.UIUtil

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.