Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8117833

Quantum: Class cast exception in WindowState.setVisible() when Swing or SWT is embedded

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • None
    • 8
    • javafx
    • None

      Run the following code and popup the combo (you will get an exception in setVisible()):


      package bugs;

      import javafx.collections.FXCollections;
      import javafx.embed.swt.FXCanvas;
      import javafx.scene.Scene;
      import javafx.scene.control.ComboBox;
      import javafx.scene.layout.GridPane;

      import org.eclipse.swt.*;
      import org.eclipse.swt.widgets.*;
      import org.eclipse.swt.layout.*;

      public class RT30307_Combo {
           private static void openTestShell(final boolean useSwtGroup,
                   final boolean useSwtCanvas) {
                Display display = new Display();
                Shell shell = new Shell(display);
                //shell.setLayout(new FillLayout());
                Composite parent = shell;
                if (useSwtGroup) {
                   Group group = new Group(parent, SWT.NONE);
                   group.setText("Group");
                   //group.setLayout(new GridLayout(1, true));
                   parent = group;
                }
                if (useSwtCanvas) {
                   Canvas swtCanvas = new Canvas(parent, SWT.NONE);
                   //swtCanvas.setLayout(new FillLayout());
                   parent = swtCanvas;
                }
          
                FXCanvas canvas = new FXCanvas(parent, SWT.BORDER);
                canvas.setBounds(25, 50, 200, 200);
          
                GridPane gridPane = new GridPane();
                Scene scene;
                scene = new Scene(gridPane);
                canvas.setScene(scene);
                ComboBox<String> myCombo = new ComboBox<String>();
                myCombo
                      .setItems(FXCollections.observableArrayList("One", "Two", "Three"));
                gridPane.add(myCombo, 0, 0);
                
                parent.pack();
                shell.pack();
                shell.open();

                while (!shell.isDisposed()) {
                    if (!display.readAndDispatch()) {
                        display.sleep();
                    }
                }
                display.dispose();
             }

          public static void main(String[] args) {
              openTestShell(true, false);
          }
      }

            snorthov Steve Northover (Inactive)
            snorthov Steve Northover (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: