Hi all, I am having trouble changing fm Swing to JavaFX using NetRexx, at first I have up and running simple controls with their event handling but the menubar is causing me problems. I cannot seem to add it to the mainwindow and show it. I have tried using menubar.getMenus().addAll(filemenu,editmenu,helpmenu) but this returns with the method "addAll"(javafx.scene.control.Menu) cannot be found in class "javafx.collections.ObservableList" or a superclass and also tried oList = ObservableList layout.getChildren() oList.add(javafx.scene.control.MenuBar menubar) but this last compiles without errors but nothing is displayed, not even the mainwindow. Thks for any help Quique import javafx. class eFM public extends Application properties inheritable static -- general variables btn = javafx.scene.control.Button() btn2 = javafx.scene.control.Button() mainwindow= stage() method main(args=String[]) public static -- can display preview and after msg before app runs Application.launch(args) method start(mainwindow1 = Stage) public -- start is a must in JavaFX programs mainwindow = mainwindow1 /* setup and create our gui */ -- create our layout layout = Borderpane() -- create our scene and add the layout layout scene1 = Scene(layout,800,500) -- create menu headers (Menu) menubar = javafx.scene.control.MenuBar() filemenu = javafx.scene.control.Menu("_File") editmenu = javafx.scene.control.Menu("_Edit") helpmenu = javafx.scene.control.Menu("_Help")
oList = ObservableList layout.getChildren() oList.add(javafx.scene.control.MenuBar menubar) -- create our test button btn = javafx.scene.control.Button() btn.setText("button 1") btn.setOnAction( eFM.buttonAction()) btn2 = javafx.scene.control.Button() btn2.setText("button 2") btn2.setOnAction( eFM.buttonAction2()) -- add controls to layout layout.setTop(menubar) layout.setLeft(btn) layout.setRight(btn2) -- set our window decorations mainwindow.initStyle(StageStyle.DECORATED) -- set our panel (scene) and show mainwindow (stage) mainwindow.setScene(scene1) mainwindow.setOnCloseRequest(eFM.exitApp()) mainwindow.show() class eFM.exitApp dependent implements EventHandler -- minor class must be declared directly after main class method handle(e=javafx.event.Event) eFM.mainwindow.close() return class eFM.buttonAction dependent implements EventHandler method handle(e=javafx.event.Event) say "button 1 pressed" eFM.btn2.setText("todo") return class eFM.buttonAction2 dependent implements EventHandler method handle(e=javafx.event.Event) say "button 2 pressed" return _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Ola Quique,
did you base these on the samples in the examples/javafx directory? There was something funny that was resolved. That’s all I remember now. best regards, René. > On 9 Apr 2020, at 13:37, Quique Britto <[hidden email]> wrote: > > Hi all, > > I am having trouble changing fm Swing to JavaFX using NetRexx, at first I have up and running simple controls with their event handling but the menubar is causing me problems. _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Hi Rene, no, I am just trying to get the basic mainwindow up and running (layout, menu and tool bar etc...) to begin actually begin coding. (i am still in the learning curve getting fm swing to javafx (never a pro)) Samples taken fm reading online only B.Rgds On Thu, 9 Apr 2020 at 13:41, René Jansen <[hidden email]> wrote: Ola Quique, _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
In reply to this post by Quique Britto
Tried as per oracle examples but now I receive no compilation errors only “javac failed” and this eFM.java:46: error: not suitable method found for add)Object) menuBar.getMenus().add((java.lang.Object)menu>File) method Collection.add(Menu) is not applicable (argument mismatch; Object cannot be converted to Menu) method List.asdd(Menu) is not applicable (argument mismatch; Object cannot be converted to Menu) Thks again for any help Quique From: [hidden email] Hi all, I am having trouble changing fm Swing to JavaFX using NetRexx, at first I have up and running simple controls with their event handling but the menubar is causing me problems. I cannot seem to add it to the mainwindow and show it. I have tried using menubar.getMenus().addAll(filemenu,editmenu,helpmenu) but this returns with the method "addAll"(javafx.scene.control.Menu) cannot be found in class "javafx.collections.ObservableList" or a superclass and also tried oList = ObservableList layout.getChildren() but this last compiles without errors but nothing is displayed, not even the mainwindow. Thks for any help Quique import javafx. oList = ObservableList layout.getChildren() _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
On Thu, Apr 9, 2020, 18:19 <[hidden email]> wrote:
Are you using the latest OpenJFX? It's a separate package no longer bundled with OpenJDK. It also requires OpenJDK 11 or above. I'm not sure if Java11 is supported by NetRexx... FC _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
In reply to this post by Quique Britto
Hola Fernando, Hope all ok! To be honest I still had Oracles JDK installed so I have removed and installed OpenJDK 8 which includes JavaFX. With the following I no longer receive any errors and compilation completes but no window is displayed. .. .. -- create menu headers (Menu) menuBar = javafx.scene.control.MenuBar() menuFile = javafx.scene.control.Menu("_File") menuEdit = javafx.scene.control.Menu("_Edit") menuHelp = javafx.scene.control.Menu("_Help") oList = ObservableList layout.getChildren() oList.add(javafx.scene.control.MenuBar menuBar) .. .. -- set our panel (scene) and show mainwindow (stage) mainwindow.setScene(scene1) mainwindow.setOnCloseRequest(eFM.exitApp()) mainwindow.show() As always any help will be much appreciated. Gracias, Quique From: [hidden email] On Thu, Apr 9, 2020, 18:19 <[hidden email]> wrote:
Are you using the latest OpenJFX? It's a separate package no longer bundled with OpenJDK. It also requires OpenJDK 11 or above. I'm not sure if Java11 is supported by NetRexx... FC _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
In reply to this post by Fernando Cassia-2
I know this to work:
import javafx.application.Application import javafx.scene.Node import javafx.scene.Scene import javafx.scene.control.TreeItem import javafx.scene.control.TreeView import javafx.scene.image.Image import javafx.scene.image.ImageView import javafx.scene.layout.StackPane import javafx.stage.Stage import javafx.collections. import javafx.geometry.Insets /* works as-is if there is a working javafx install */ /* illustrates the cast needed for add to ObservableList */ class TreeViewSampleNRX extends Application method main(args=String[]) static launch(args) method start(stage=Stage) root = StackPane() root.setPadding(Insets(10, 10, 10, 10)) oList = ObservableList root.getChildren() rootItem = TreeItem("Inbox", null) rootItem.setExpanded(1) loop i=1 to 6 item = TreeItem("Message" i) pList = ObservableList rootItem.getChildren() plist.add(item) end tree = TreeView(rootItem) oList.add(tree) stage.setTitle("NetRexx Tree View Sample") stage.setScene(Scene(root, 528, 192)) stage.show() Indeed, NetRexx compiles do not work on Java 11 - and 3.09, in which you can use a native compiler on Mac and Linux - Windows is actually holding up the release - it might. The above works with Java 8 and a JavaFx for that I got somewhere. René.
_______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Free forum by Nabble | Edit this page |