The example (10) and the instance (11) Describe how to add an event handle to the button, and the instance (10) is the effect before the handle is added, and the instance (11) is the effect after the handle is added.
This example code is as follows:
Import javafx.application.Application;
Import Javafx.geometry.Pos;
Import Javafx.scene.Scene;
Import Javafx.scene.control.Button;
Import Javafx.scene.layout.StackPane;
Import Javafx.scene.layout.HBox;
Import Javafx.scene.layout.BorderPane;
Import Javafx.scene.paint.Color;
Import javafx.scene.shape.Circle;
Import Javafx.stage.Stage;
public class Controlcirclewithouteventhandling extends application {
@Override//Override The Start method in the Application class
public void Start (Stage primarystage) {
Stackpane pane = new Stackpane ();
Circle circle = New Circle (50);
Circle.setstroke (Color.Black);
Circle.setfill (Color.White);
Pane.getchildren (). Add (circle);
HBox HBox = new HBox ();
Hbox.setspacing (10);
Hbox.setalignment (Pos.center);
Button Btenlarge = New button ("enlarge");
Button Btshrink = New button ("Shrink");
Hbox.getchildren (). Add (Btenlarge);
Hbox.getchildren (). Add (Btshrink);
Borderpane Borderpane = new Borderpane ();
Borderpane.setcenter (pane);
Borderpane.setbottom (HBox);
Borderpane.setalignment (HBox, Pos.center);
Scene scene = new Scene (borderpane,200,150);
Primarystage.settitle ("controlcircle");
Primarystage.setscene (Scene);
Primarystage.show ();
}
}
The results of the operation are as follows:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4E/37/wKiom1RgUZmydNjIAACN4sF5bxg340.jpg "title=" Picture 1.png "alt=" Wkiom1rguzmydnjiaacn4sf5bxg340.jpg "/>
This article is from the "Fengbin Technology blog" blog, make sure to keep this source http://fengbin8606.blog.51cto.com/8840305/1574982
Fengbin: JavaFX Instance (10) "Controlcirclewithouteventhandling"