Erreur au rajout d'elements
Bonjour,
J'essaye de creer un mini-programme, contenant une selection.
Quand je fais un choix dans une ComboBox, ce dernier est sense retourne un changement niveau de la page, mais ce dernier retourne une erreur. J'ai essaye de troobleshoot, mais en vain.
Code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| package fr.henrid.mathutilities;
import java.awt.Button;
import java.awt.TextField;
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class Main extends Application{
public void start(Stage stage){
final VBox pane = new VBox();
pane.setAlignment(Pos.TOP_CENTER);
final Text alpha = new Text("ALPHA - DO NOT DISTRIBUTE");
alpha.setFont(Font.font("Sans Serif", FontWeight.BOLD, FontPosture.REGULAR, 16));
pane.getChildren().add(alpha);
final ComboBox actionChoose = new ComboBox();
actionChoose.setPromptText("Please Select a Method");
actionChoose.getItems().add("Binary -> Base 10");
actionChoose.getItems().add("Base 10 -> Binary");
actionChoose.valueProperty().addListener(new ChangeListener() {
public void changed(ObservableValue vo, Object t, Object t1) {
// Result: T1
String result = new String(t1.toString());
if(result.equals("Binary -> Base 10")){
pane.getChildren().clear();
pane.getChildren().add(alpha);
pane.getChildren().add(actionChoose);
TextField input1 = new TextField();
Button calculate = new Button("Calculate");
//pane.getChildren().add(input1);
//action.getChildren().add(calculate);
}
}
});
pane.getChildren().add(actionChoose);
stage.setScene(new Scene(pane, 780,500));
stage.setTitle("Maths Utilities v1.0A");
stage.setResizable(false);
stage.show();
}
public static void main(String[] args){
launch(args);
}
} |