Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.Component;
import java.awt.Container;

import javax.swing.AbstractButton;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;

public class Main {
    public static void main(String[] args) {
        String[] items = { "A", "B", "C", "D" };
        JComboBox<String> combo = new JComboBox<String>(items);
        combo.setEditable(true);

        removeButton(combo);

        JOptionPane.showMessageDialog(null, combo);
    }

    private static void removeButton(Container container) {
        Component[] components = container.getComponents();
        for (Component component : components) {
            if (component instanceof AbstractButton) {
                container.remove(component);
            }
        }
    }
}