title: Swing and javafx
body: <p>I am trying to put a resized media player in a swing tabbed pane. The only way I can find to resize the media is to use a media view. But when I try to add the controller I get MediaControl cannot be cast to javafx.scene.Group.</p>
  
  <p>My code is;</p>
  
  <pre><code>import javax.swing.JFrame;
  import javax.swing.JPanel;
  import javax.swing.JTabbedPane;
  import javax.swing.SwingUtilities;
  import javafx.application.Platform;
  import javafx.embed.swing.JFXPanel;
  import javafx.scene.Group;
  import javafx.scene.Scene;
  import javafx.scene.media.Media;
  import javafx.scene.media.MediaPlayer;
  import javafx.scene.media.MediaView;
  
  public class JavaFX_insideTab {
  
  private static final String MEDIA_URL = "http://download.oracle.com/otndocs/products/javafx/oow2010-2.flv";
  
  private static void initFxLater(JFXPanel panel) {
      Group root = new Group();
      Scene scene = new Scene(root, 450, 200);
      // create media player
      Media media = new Media(MEDIA_URL);
      MediaPlayer mediaPlayer = new MediaPlayer(media);
      mediaPlayer.setAutoPlay(true);
  
      MediaView mediaView = new MediaView(mediaPlayer);
  
      mediaView.setFitWidth(450);
      mediaView.setFitHeight(200);
  
      MediaControl mediaControl = new MediaControl(mediaPlayer);
      scene.setRoot(mediaControl);
  
      ((Group) scene.getRoot()).getChildren().add(mediaView);
  
          panel.setScene(scene);
  }
  
  private static void initSwingLater() {
      JFrame jFrame = new JFrame("- JFrame -");
      jFrame.setSize(540, 426);
      jFrame.setVisible(true);
      jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      jFrame.getContentPane().setLayout(null);
  
      final JFXPanel jFXPanel = new JFXPanel();
      jFXPanel.setBounds(0, 0, 540, 188);
  
      JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
      tabbedPane.setBounds(0, 0, 528, 392);
      jFrame.getContentPane().add(tabbedPane);
  
      JPanel panel = new JPanel();
      tabbedPane.addTab("New tab", null, panel, null);
      JPanel playerpanel = new JPanel();
      tabbedPane.addTab("Media Player", null, playerpanel, null);
  
      JPanel panel_1 = new JPanel();
      playerpanel.add(jFXPanel);
  
      Platform.runLater(new Runnable() {
  
      @Override
      public void run() {
      initFxLater(jFXPanel);
      }
      });
  
  }
  
  public static void main(String[] args) {
  SwingUtilities.invokeLater(new Runnable() {
  
  @Override
      public void run() {
          initSwingLater();
      }
  
      });
  }
  </code></pre>
  
  <p>}</p>
  
  <p>where am I going wrong?</p>