JPro-one / jpro-routing

Small web-framework for JPro
https://www.jpro.one
Apache License 2.0
6 stars 0 forks source link

LinkUtil.setLink() or LinkUtil.gotoPage() can't be set to Javafx MenuItem? #12

Open ctoabidmaqbool opened 1 year ago

ctoabidmaqbool commented 1 year ago

Hi! I am facing another issue, that's LinkUtil.setLink() can't be set to Javafx MenuItem? As LinkUtil.setLink() only accepts Nodes. What is the currently solution?

Sample code for testing:

javafx.scene.control.MenuItem menuItemSubCategory = new MenuItem("Category");
LinkUtil.setLink(menuItemSubCategory, "/?buizCategory=");

This error is showing:

D:\NetBeansProjects\MyAPP\src\main\java\com\myapp\module\ImageSlider.java:447: error: incompatible types: MenuItem cannot be converted to Node
LinkUtil.setLink(menuItemSubCategory, "/?buizCategory="+ menuItemSubCategory.getText().replaceAll(" ", "%20"));

Or

javafx.scene.control.MenuItem menuItemSubCategory1 = new MenuItem("Category");
menuItemSubCategory1.setOnAction(event -> {
        LinkUtil.gotoPage(menuItemSubCategory1, "/?buizCategory=" + menuItemSubCategory1.getText().replaceAll(" ", "%20"));
});

Then this error is showing!

D:\NetBeansProjects\MyAPP\src\main\java\com\myapp\module\ImageSlider.java:447: error: incompatible types: MenuItem cannot be converted to Node
LinkUtil.gotoPage(menuItemSubCategory1, "/?buizCategory=" + menuItemSubCategory1.getText().replaceAll(" ", "%20"));
FlorianKirmaier commented 1 year ago

Yes, that's a quite an annoying topic. You don't get the Node of the MenuItem by default. I have to look into it, but I'm unsure whether it's solvable.