import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Bug4185024 {

    public JFrame createUIAndTest() throws Exception {

        final JFrame[] jFrames = new JFrame[1];
        final JPanel panel = new JPanel();
        final JComboBox months = new JComboBox();
        months.addItem("January");
        months.addItem("February");
        months.addItem("March");
        months.addItem("April");
        months.addItem("May");
        months.addItem("June");
        months.addItem("July");
        months.addItem("August");
        months.addItem("September");
        months.addItem("October");
        months.addItem("November");
        months.addItem("December");
        months.getAccessibleContext().setAccessibleName("Months");
        months.getAccessibleContext().setAccessibleDescription("Choose a month of the year");

        // Set this to true and the popup works correctly...
        months.setLightWeightPopupEnabled(false);

        final JDesktopPane desktop = new JDesktopPane();
        final JInternalFrame jf = new JInternalFrame("ComboBox Bug" );

        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                jFrames[0] = new JFrame("Test 4323121");
                panel.setLayout(new BorderLayout());
                jf.setResizable(true);
                jf.setSize(200,200);
                JPanel iPanel = new JPanel();
                JButton button = new JButton("Press Me");
                button.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        System.out.println("Button Pressed");
                    }
                });
                iPanel.add(button);
               // iPanel.add(months);
                //jf.getContentPane().add(iPanel);
                jf.getContentPane().add(months);
                jf.pack();
                jf.show();
                desktop.add( jf );
                panel.add( desktop );
                jFrames[0].getContentPane().add(panel);
                jFrames[0].setSize(600,400);
                jFrames[0].setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                jFrames[0].setVisible(true);
            }
        });

        return jFrames[0];
    }

    public static void main(String []args) throws Exception {
        Bug4185024 bug4185024 = new Bug4185024();
        JFrame frame[] = new JFrame[1];
        try{
            frame[0] = bug4185024.createUIAndTest();
        }finally {
            SwingUtilities.invokeAndWait(new Runnable() {
                @Override
                public void run() {
                    if (frame[0] != null) {
                        //frame[0].dispose();
                        System.out.println("Frame got disposed");
                    }
                }
            });
        }
    }
}

