@Julo0sS I am unsure if I understood it correctly. So you would create an Interface or an enum or something and let your controllers subscribe to the EventBus. And whenever you hit a button a value is sent on the EventBus and that will notify all (subscribed) controllers which then will check (with the value of enum for example) if they are responsible for handling the event?
Actually i tried it this way : i created my "CustomEventBus" singleton way. I get the instance of it in any "subscriber" component. Then, in my components, I define a function that will handle "myEvent". MyEvent can be triggered from anywhere, by anything
Then you only have to determine somehow if MyEvent is supposed to activate something somewhere. If you have 10 controllers subscribed, a button click might only trigger something in one controller. Or maybe different actions on one controller
@geisterfurz007 you register your "subscribers" in the eventbus. Then when the eventbus gets something it tells the subscribers. paste.ofcode.org/Tj9SifUDZNqMpx6UCAJ6Si Don't just copy/paste, all classes & templates are there. this is a dumb example quickly made... ;) It makes me think about the observer pattern
you "fire an event" this way : eventBus.post(whateverObject)
and you handle it this way : handle(WhateverObject whateverObject)
so, if the "subscriber" receives an event with a "WhateverObject", then it does something. If it receives an event with a "SomethingElseObject", it does nothing...
Yeah hence my idea with the enum. Would need a line with if (myEnumValue != MyEnum.SPECIAL_EVENT) return; each time though. But enables multiple events in one method without multiple subscriptions in each Controller
@geisterfurz007 yeah. To me the advantage of this, in my case, is that I can use it in any component, I don't care if they are related or not. I can use this to trigger updates, but also to call "children" from another level "child" without having to notice the "parent" component
@Pigman168 Welcome to the Java Chat, the room for Java enthusiasts! Please use a code snippet tool when posting code snippets. If you have an Android question, you're in the wrong place! And remember: this is not tech support! Thanks for visiting and have fun! :D
I think you should consider it not returning an Object, but yes, if you need to use the returned value multiple times, you have to put it in a variable
if you want to have a certain object based on the input, you will have to parse the string to your object
aka, if you have an enum (EXIT, DO_SOMETHING, DO_NOTHING) and you want to convert your string to that enum, you check if it matches any of the values and choose the one it matches
if it doesnt match, you return a null value
enums have this behavior by default
but you can easily make it for any class using a Map<String, MyClass>
which maps instances of "MyClass" based on some "String"
@geisterfurz007 javafxclassjavafx.stage.Stage: The JavaFX Stage class is the top level JavaFX container. The primary Stage is constructed by the platform. Additional Stage objects may be constructed by the application. @since JavaFX 2.0 (1/21)
@linuscl Welcome to the Java Chat, the room for Java enthusiasts! Please use a code snippet tool when posting code snippets. If you have an Android question, you're in the wrong place! And remember: this is not tech support! Thanks for visiting and have fun! :D
@Wietlol yeah, but I can paste my css files and everything goes fine. Think I got to this message when I tried to edit "file & code templates". Right click on a package, new, edit file templates. Css will not appear in the list...
then, i did just right click on my package, new, "File", typed "myFileName.css", and a small banner appears at top of my file with this message :
*.css files are supported by IntelliJ IDEA Ultimate Edition (check..., do not suggest..., ignore)
Each Node has a read-only boundsInLocal variable which specifies the bounding rectangle of the Node in untransformed local coordinates. boundsInLocal includes the Node's shape geometry, including any space required for a non-zero stroke that may fall outside the local position/size variables, and its clip and effect variables.
SceneBuilder -> GridPane is bound to right side of the AnchorPane and moves right, when I resize with right side. Application -> GridPane doesn't give a fuck and stays where it is
Ah I found the issue with mine... for whatever reason the resize is not passed to the childrenPane (or something). In SceneBuilder the standalone Scene works, but the whole construct does not either -.-
When you write this : <Label text="My Text"></Label>. The FXML instanciates a Label item, and what is it doing to set the text property? Is it calling the "setText" on the Label instance?
there are several other solutions, like css with "-fx-graphic". But in my case, I did implement ImageButton which works pretty fine javafx side, there is certainly a way to make it work the same fxml side...
@ItachiUchiha I have a private String imageUrl defined in my ImageButton class. It does not work when I try to put imageUrl attribute in the ImageButton tag...
I am unsure which you all need, but you should add get, and set (which will return the values of it, that you can get/set by using the according methods on the Property) and <name>Property which will return the Property
It you create the FXML in the same project or you add a jar which contains the definition of ImageButton, everything in the class-path and the FXML can import the class
I have a spring-boot server app. In one of the function I run some scheduled threads:
private ScheduledExecutorService pool = Executors.newScheduledThreadPool(10);
private threadsNumber = 10;
@PostConstruct
void startThreads() {
for (int i = 1; i <= threadsNumber; ++i)...
@HaskellFun Welcome to the Java Chat, the room for Java enthusiasts! Please use a code snippet tool when posting code snippets. If you have an Android question, you're in the wrong place! And remember: this is not tech support! Thanks for visiting and have fun! :D
1 hour later…
user7627726
18:33
Can anyone help me? I think I might have stumped stackOverflow itself.
Is there any way to close the Eclipse Neon console within a program? It is normally exited by clicking the exit button in the top-left of console, but I am wondering if there is some command I can use, or some other alternative.
I know I can terminate the program by using System.exit(0), but I wa...
@hawkfalcon Welcome to the Java Chat, the room for Java enthusiasts! Please use a code snippet tool when posting code snippets. If you have an Android question, you're in the wrong place! And remember: this is not tech support! Thanks for visiting and have fun! :D