我是JAVAFX的新手,请帮我修改下面的代码,因为BorderPane没有显示添加到其中的元素。
我是否需要调用BORDERPANE类中的任何方法。 另外请告诉我BorderPane如何工作的基本想法。 如果对BorderPane有任何替代方法,请告诉我。
import java.text.DecimalFormat;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Orientation;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.ListView;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.Slider;
import javafx.scene.control.TextArea;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class effects extends Application {
public void start(Stage s) {
Group root = new Group();
VBox vb = new VBox();
LabeledTextPane ltp1=new LabeledTextPane("abd","ad",Color.BLACK);
LabeledTextPane ltp2=new LabeledTextPane("abd","ad",Color.BLACK);
LabeledTextPane ltp3=new LabeledTextPane("abd","ad",Color.BLACK);
HBox hb1=new HBox();
HBox hb2=new HBox();
VBox vb1=new VBox();
VBox vb2=new VBox();
GridPane gp=new GridPane();
hb1.getChildren().addAll(ltp1,ltp2,ltp3);
Button b = new Button("Change X");
Button b1 = new Button("Change Y");
Button b2 = new Button("Change Speed");
Button b3 = new Button("Race Car");
Button b4 = new Button("Clear All");
Button b5 = new Button("Quit");
hb2.getChildren().addAll(b,b1,b2,b3,b4,b5);
Slider sl = new Slider(-150, 150, 0); // min, max, initial values
sl.setMajorTickUnit(75);
sl.setMinorTickCount(25);
sl.setShowTickMarks(true);
sl.setShowTickLabels(true);
sl.setOrientation(Orientation.HORIZONTAL);
Slider Sy = new Slider(-150, 150, 0); // min, max, initial values
Sy.setMajorTickUnit(75);
Sy.setMinorTickCount(25);
Sy.setShowTickMarks(true);
Sy.setShowTickLabels(true);
Sy.setOrientation(Orientation.HORIZONTAL);
LabeledTextPane ltp4=new LabeledTextPane("Time"," ",Color.BLACK);
LabeledTextPane ltp5=new LabeledTextPane("Distance"," ",Color.BLACK);
vb1.getChildren().addAll(sl,Sy,ltp4,ltp5);
Slider sl2 = new Slider(0, 80, 0); // min, max, initial values
sl2.setMajorTickUnit(20);
sl2.setMinorTickCount(5);
sl2.setShowTickMarks(true);
sl2.setShowTickLabels(true);
sl2.setOrientation(Orientation.HORIZONTAL);
LabeledTextPane ltp6=new LabeledTextPane("Time"," ",Color.BLACK);
LabeledTextPane ltp7=new LabeledTextPane("Angle"," ",Color.BLACK);
LabeledTextPane ltp8=new LabeledTextPane("New X Coordinate"," ",Color.BLACK);
LabeledTextPane ltp9=new LabeledTextPane("New Y Coordinate"," ",Color.BLACK);
vb2.getChildren().addAll(sl2,ltp6,ltp7,ltp8,ltp9);
gp.setAlignment(Pos.CENTER);
hb1.setAlignment(Pos.CENTER);
hb2.setAlignment(Pos.CENTER);
vb1.setAlignment(Pos.CENTER);
vb2.setAlignment(Pos.CENTER);
BorderPane p=new BorderPane();
p.setTop(hb1);
p.setBottom(hb2);
p.setLeft(vb1);
p.setRight(vb2);
p.setCenter(gp);
root.getChildren().add(p);
vb.getChildren().addAll(hb1,hb2,vb1,vb2,gp);
Scene scene = new Scene(root, 800, 800, Color.BLACK);
s.setTitle("Control Play");
s.setScene(scene);
s.show();
}
public static void main(String [] args) {
launch(args);
}
}