I'm trying to create a TextField
to get a users name. I've created a new class for containing UI components.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class start extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Label label = new Label("Name:");
TextField textField = new TextField();
HBox hBox = new HBox();
hBox.getChildren().addAll(label,textField);
hBox.setSpacing(10);
Scene scene = new Scene(hBox,300,200);
primaryStage.setScene(scene);
primaryStage.setTitle("Hello");
primaryStage.show();
}
}
I want to get the name entered in the "Hello" window to use it in another class ShowOff
.
ShowOff Class
import javafx.application.Application;
public class ShowOff {
ShowOff() {
Application.launch(start.class,"myClass");
}
public static void main(String[] args)
{
}
}
How could I implement that?