How to add actions on JFXButton
See original GitHub issueExcuse me, I encountered a problem, the Action has been added to fxml, but it does not take effect in the Controller. My English is not very good, I found many articles, but I couldn’t find it. If anyone knows, please tell me. Thank you
fxml
<!-- 水平布局盒子-->
<HBox spacing="20" style="-fx-padding: 0 0 0 50;">
<JFXButton prefWidth="100" prefHeight="40" buttonType="RAISED" text="BUTTON"
style="-fx-font-size:14px;-fx-background-color:WHITE;" onAction="#click"/>
<JFXButton prefWidth="100" prefHeight="40" buttonType="RAISED" text="COLORED"
style="-fx-text-fill:WHITE;-fx-background-color:#5264AE;-fx-font-size:14px;"/>
<JFXButton prefWidth="100" prefHeight="40" buttonType="RAISED" text="DISABLED"
style="-fx-background-color:WHITE;-fx-font-size:14px;" disable="true"/>
</HBox>
Controller
@ViewController(value = "/fxml/Button.fxml")
public final class ButtonController {
public void click(ActionEvent mouseEvent) {
System.out.println();
}
}
it dose not work .can you tell me reason?
Issue Analytics
- State:
- Created 3 years ago
- Comments:9
Top Results From Across the Web
Adding EventHandler to JavaFX Button - Baeldung
We learned how to add event handlers to JavaFX buttons and execute different actions depending on the type of event.
Read more >com.jfoenix.controls.JFXButton.setOnAction java code examples
getChildren().add(glyphDetailViewer); ScrollPane scrollableGlyphs ... setOnAction((action) -> { FileChooser fileChooser = new FileChooser(); FileChooser.
Read more >How to add an image to a button (action) in JavaFX?
You can create a Button by instantiating the javafx.scene.control.Button class. ... Create an ImageView object using the image object.
Read more >com.jfoenix.controls.JFXButton#setOnAction
CENTER); //Create the 'ok'/close button JFXButton button = new JFXButton("ok"); //set button action listner for closing the alert button.
Read more >Create new Button and Set Action Listener in JavaFX
1. Create a JavaFX Button. Import javafx.scene. · 2. Button Text. Set text for the JavaFX Button using Button. · 3. Set Action...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok so here is what I understand. Take a look at the datafx tutorial 1.
I think what you are missing is the
@ActionMethod('button-fx-id')
annotation.If just adding that does not work you may have to add the
@ActionTrigger('button-fx-id')
annotation too.Here is my wechat id: https://pastebin.com/kwzgBDkA