Posted By

Shoox on 01/11/13


Tagged

java widget top javafx


Versions (?)

JavaFX always on top


 / Published in: Java
 

The dirty hack you'll have to do, if you want to keep your JavaFX application always on top (e.g. as widget).

  1. package at.kevinschmid;
  2.  
  3. import javafx.application.Platform;
  4. import javafx.embed.swing.JFXPanel;
  5. import javafx.scene.Group;
  6. import javafx.scene.Scene;
  7. import javafx.stage.Stage;
  8.  
  9. import javax.swing.JDialog;
  10.  
  11. public class Start extends javafx.application.Application {
  12. public static void main( String[] args ) {
  13. launch(args);
  14. }
  15.  
  16. @Override
  17. public void start( final Stage stage ) throws Exception {
  18. final JDialog jDialog = new JDialog();
  19. final Scene scene = new Scene(new Group());
  20. final JFXPanel fxPanel = new JFXPanel();
  21. Platform.runLater(new Runnable() {
  22. @Override
  23. public void run() {
  24. fxPanel.setScene(scene);
  25. }
  26. });
  27. jDialog.add(fxPanel);
  28. jDialog.setAlwaysOnTop(true);
  29. jDialog.setVisible(true);
  30. }
  31. }

Report this snippet  

You need to login to post a comment.