JavaFX Event Handling using Scene Builder 🎪

preview_player
Показать описание
JavaFX Handling Events using Scene Builder tutorial example explained

#JavaFX #Event #Handling

package application;

public class Controller {

@FXML
private Circle myCircle;
private double x;
private double y;

public void up(ActionEvent e) {
}
public void down(ActionEvent e) {
}
public void left(ActionEvent e) {
}
public void right(ActionEvent e) {
}

}
Bro Code merch store 👟 :
===========================================================
===========================================================

music credits 🎼 :
===========================================================
Creative Commons — Attribution-ShareAlike 3.0 Unported— CC BY-SA 3.0
===========================================================
Рекомендации по теме
Комментарии
Автор

I have paid for the courses, But your tutorials beat them all in Quality and delivery. Thanks Bro.

dablo
Автор

If anyone is confused why there is no drop down for application.Controller at 3:44, it helped to drag the Main.fxml file into the application folder like he did in the previous video. That makes everything work again

and as always, thanks bro ;)

stas
Автор

i have done it. Thanks. I from Russia and I like your videos about JAVA

locky
Автор

package application;

import
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Parent;
import javafx.scene.Scene;


public class Main extends Application {

@Override
public void start(Stage stage) {
try {
Parent root =
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
} catch(Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) {
launch(args);
}
}


<?xml version="1.0" encoding="UTF-8"?>

<?import
<?import
<?import javafx.scene.shape.Circle?>

<children>
<Button layoutX="285.0" layoutY="14.0" mnemonicParsing="false" onAction="#up" text="UP" />
<Button layoutX="534.0" layoutY="188.0" mnemonicParsing="false" onAction="#right" text="RIGHT" />
<Button layoutX="274.0" layoutY="361.0" mnemonicParsing="false" onAction="#down" text="DOWN" />
<Button layoutX="14.0" layoutY="188.0" mnemonicParsing="false" onAction="#left" text="LEFT" />
<Circle fx:id="myCircle" fill="DODGERBLUE" layoutX="301.0" layoutY="201.0" radius="100.0" stroke="BLACK" strokeType="INSIDE" />
</children>
</AnchorPane>


package application;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.shape.Circle;


public class Controller {

@FXML
private Circle myCircle;
private double x;
private double y;

public void up(ActionEvent e) {


}
public void down(ActionEvent e) {


}
public void left(ActionEvent e) {


}
public void right(ActionEvent e) {


}

}

BroCodez
Автор

I have been following u're javafx tutorial u teach better than university prof

coderXplus
Автор


opens <package> to javafx.fxml; (in your case <package> is probably "application")

you just have to manually write that code into your fxml file so it looks like this:

module SceneBuilderEventHandling {
requires javafx.graphics;
requires javafx.controls;
requires javafx.fxml;
requires javafx.base;

opens application to javafx.fxml;

exports application;
}

thedev
Автор

Excellent tutorials. Bro is a good teacher💪

felixnyamongo
Автор

I just clicked the ad to support you... 😍🙏

xplane
Автор

Only You helps me
(Better Than my Teacher)

ctluwua
Автор

I like your videos. You are the best BRO

Vladislav-wo
Автор

Thank you. You made this easy to understand.

sam-williams
Автор

The Controllers drop-down is missing on my IntelliJ. So, what I did was, I selected the Text tab at the bottom of the FXML file (there are Text and Scene Builder tabs), went to the opening AnchorPane tag, and modified the fx:controller attribute to the controller I set up (in my case, I made it: And it worked. And the methods showed up in the drop-downs in the Code drop-down on the right panel of the buttons in the Scene Builder tab.

abelxotessema
Автор

I'm confused on how the x and y are connected to the circle? like ok we hook the circle in scene builder with the myCircle instance, however then we add two doubles which we never initialize and then we tell the methods to use this value for setting the position of the circle, how does the program know what we mean to do?

kole
Автор

Thanks a lot for your efforts, It helps a lot

mohamedaliwalha
Автор

Thumb up, great work!!! ... as usual 😉

tomaszkarolak
Автор

I have a question. Aren't x and y initialized to 0? That is, when we press, say, up, the first time, shouldn't the y-value of the center of the circle actually be -10, thus moving it to (0, -10)?

abelxotessema
Автор

Im from Java tutorial just to see if you're still uploading, keep it up!

keanz
Автор

Dude, i'm in love with these emojis hahaha ♥♥

boultifnidhal
Автор

So does the scene builder replace the event handler method with the one we provide?

thCrusade
Автор

Actually, Bro I have started learning java rather than stuffing my mind with alot of languages. I don't know yet its end point. I want bro you to help me to learn java well. I will be very thankful to you in my entire life.

malikshahzaib