Java Reference
In-Depth Information
where
T
is the appropriate event object,
MouseEvent
for the
onMouseDragged
and
onMousePressed
event handlers, and
ActionEvent
for the
onAction
event handlers. A method that does not take any arguments can also be set as event
handler methods. You can use such a method if you do not plan to use the event object.
Now that we understand the FXML file, we move on to the controller class next.
Understanding the Controller
Listing 3-2 shows the controller class that works with the FXML file we created in the last subsection.
Listing 3-2.
StageCoachController.java
package projavafx.stagecoach.ui;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class StageCoachController {
@FXML
private Rectangle blue;
@FXML
private VBox contentBox;
@FXML
private Text textStageX;
@FXML
private Text textStageY;
@FXML
private Text textStageH;
@FXML
private Text textStageW;
@FXML
private Text textStageF;
Search WWH ::
Custom Search