Subclassing JavaFX Stage / Scene -


coming swing , being new javafx tried subclass java fx stages , scenes. run problems, init method not being of subclassed sceen not being found during initialization.

so wondering: java fx stages , sceens subclassed 1 subclass jframes , jpanels in swing or discouraged?

you can subclass scene , stage , many other fx library classes in pretty same way. i'm not sure i'd recommend it, , doesn't seem style appears in of examples official tutorials. (in fact, long ago stopped using subclasses of jframe , jpanel in vast majority of swing code, preferring instead more style in fx examples.)

but it's possible:

import javafx.application.application; import javafx.scene.scene; import javafx.scene.control.label; import javafx.scene.layout.stackpane; import javafx.stage.stage;  public class subclassingexample extends application {      @override     public void start(stage defaultstageignored) {         stage stage = new mystage();         stage.show();     }      public static class mystackpane extends stackpane{         public mystackpane() {             getchildren().add(new label("hello world"));         }     }      public static class myscene extends scene {         public myscene() {             super(new mystackpane(), 250, 75);         }     }      public static class mystage extends stage {         public mystage() {             setscene(new myscene());         }     }      public static void main(string[] args) {         launch(args);     } } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -