Hi,

With OpenJDK build b23, on recent GTK versions, showing a JComboBox when GTKLookAndFeel is active causes this assertion failure:

(<unknown>:11755): Gtk-WARNING **: Attempting to add a widget with type
GtkButton to a GtkComboBoxEntry (need an instance of GtkEntry or of a subclass)

The assertion was added in this commit:

http://svn.gnome.org/viewcvs/gtk+?view=revision&revision=17657

Attached is a test case demonstrating the failure and a patch to fix it.  The
patch eliminates theme engines' ability to special-case the arrow button/text
field combination but given the new assertion this appears to be the best
option.  Visually, JComboBox still looks fine under the theme engines shipped
with Fedora 8.

Tom

import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

public class GTKLookAndFeelComboBoxTest {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                try {
                    UIManager.setLookAndFeel
                        ("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
                } catch (Exception e) {
                    System.out.println("caught: " + e);
                }
                JFrame frame = new JFrame();
                frame.add(new JComboBox());
                frame.setSize(150, 50);
                frame.show();
            }
        });
    }
}

--- openjdk/jdk/src/solaris/native/sun/awt/gtk2_interface.c.orig	2007-09-27 04:08:04.000000000 -0400
+++ openjdk/jdk/src/solaris/native/sun/awt/gtk2_interface.c	2007-10-04 16:31:04.000000000 -0400
@@ -1410,20 +1410,6 @@
             (*fp_gtk_menu_item_set_submenu)((GtkMenuItem*)root_menu, result);
             (*fp_gtk_menu_shell_append)((GtkMenuShell *)menu_bar, root_menu);
         }
-        else if (widget_type == COMBO_BOX_ARROW_BUTTON ||
-                 widget_type == COMBO_BOX_TEXT_FIELD)
-        {
-            /*
-             * We add a regular GtkButton/GtkEntry to a GtkComboBoxEntry
-             * in order to trick engines into thinking it's a real combobox
-             * arrow button/text field.
-             */
-            GtkWidget *combo = (*fp_gtk_combo_box_entry_new)();
-            (*fp_gtk_container_add)((GtkContainer *)combo, result);
-            (*fp_gtk_container_add)((GtkContainer *)gtk2_fixed, combo);
-            (*fp_gtk_widget_realize)(result);
-            return result;
-        }
         else if (widget_type != TOOL_TIP &&
                  widget_type != INTERNAL_FRAME &&
                  widget_type != OPTION_PANE)

Reply via email to