问题描述:

I have created login form and a "my profile" named scene. So when user logs in it changes to the "my profile scene" but the informations don't get updated. How to store the user data in the my profile scene?

I have used a user & user service class to store user information from which i can login. Now i want the logged in informations to be printed on "my profile" scene.

网友答案:
package Profile;

 import carrentalservice.CarRentalService;
 import carrentalservice.Customer;
 import carrentalservice.CustomerService;
 import javafx.event.ActionEvent;
 import javafx.event.EventHandler;
 import javafx.scene.Scene;
 import javafx.scene.control.Label;
 import javafx.scene.layout.VBox;
 import javafx.geometry.Insets;
 import javafx.geometry.Pos;
 import javafx.scene.control.Button;
 import javafx.scene.control.TextField;
 import javafx.scene.layout.Region;
 import javafx.stage.Stage;

public class Profile extends Scene {

Label MyProfileLabel;
Label UserIDLabel;
Label NameLabel;
Label GenderLabel;
Label LocationLabel;
TextField UserIDTextField;
TextField NameTextField;
TextField GenderTextField;
TextField LocationTextField;

static VBox root = new VBox(10);

public Profile(){

    super(root,500,350);





            MyProfileLabel=new Label("My Profile");
            MyProfileLabel.setId("label-custom");
            UserIDLabel=new Label("ID");
            NameLabel=new Label("Name");
            GenderLabel=new Label("Gender");
            LocationLabel=new Label("Location");

            UserIDTextField=new TextField();
            UserIDTextField.setMinWidth(Region.USE_PREF_SIZE);
            UserIDTextField.setMaxWidth(Region.USE_PREF_SIZE);




            NameTextField=new TextField();
            NameTextField.setMinWidth(Region.USE_PREF_SIZE);
            NameTextField.setMaxWidth(Region.USE_PREF_SIZE);

            GenderTextField=new TextField();
            GenderTextField.setMinWidth(Region.USE_PREF_SIZE);
            GenderTextField.setMaxWidth(Region.USE_PREF_SIZE);

            LocationTextField=new TextField();
            LocationTextField.setMinWidth(Region.USE_PREF_SIZE);
            LocationTextField.setMaxWidth(Region.USE_PREF_SIZE);


    root.setPadding(new Insets(10));
    root.getChildren().addAll(MyProfileLabel,UserIDLabel,UserIDTextField,NameLabel,NameTextField,GenderLabel,GenderTextField,LocationLabel,LocationTextField);
            root.setAlignment(Pos.CENTER);
            root.getStylesheets().add("ProViper.css");   







}

}

相关阅读:
Top