Hello, I am having a problem with my application. I have designed a class - DisplayClientRequest which has a constructor and some setters and getter. Apart from this i built very simple JavaFX GUI application. For instance if I create a method in my DisplayClientRequest with paramteres, how would I pass these parameters to labels ? For example if I pass name and surname in my method I would like the name and surname to appear in the label. Is it possible to achieve ?
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package busypointltd;
import java.util.Date;
/**
*
* @author Bartosz
*/
public class DisplayClientRequest {
private String name, surname;
private Date date;
private String[] advertisementType, marketingType;
private short marketingDuration;
//Constructor
public DisplayClientRequest(String name, String surname){
this.name = name;
this.surname = surname;
}
public static DisplayClientRequest getClientRequest(String name, String surname){
DisplayClientRequest b = setClientRequest(name, surname);
System.out.println(name + " " + surname);
return b;
}
private static DisplayClientRequest setClientRequest(String name, String surname){
DisplayClientRequest details = new DisplayClientRequest(name, surname);
return details;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
}
and GUI
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package busypointltd;
/**
*
* @author Bartosz
*/
import java.awt.Rectangle;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.shape.Circle;
import javafx.stage.Modality;
public class DisplayRequestGUI {
public static void displayRequest(){
Stage window = new Stage();
window.initModality(Modality.APPLICATION_MODAL);
BorderPane pane = new BorderPane();
HBox buttons = new HBox();
Button btnContinue = new Button("Continue");
btnContinue.setStyle(" -fx-base: #b6e7c9;");
Button btnCancel = new Button("Cancel");
btnCancel.setStyle(" -fx-base: #FF1919;");
buttons.getChildren().addAll(btnContinue, btnCancel);
buttons.setAlignment(Pos.CENTER);
buttons.setPadding(new Insets(10, 10, 10, 10));
buttons.setSpacing(10.0);
pane.setBottom(buttons);
VBox labels = new VBox();
Label name = new Label();
name.setText("a");
labels.getChildren().addAll(name);
pane.setCenter(labels);
Scene scene = new Scene(pane, 800, 600);
window.setScene(scene);
window.setTitle("s");
window.showAndWait();
}
}
Of course I have the main class to launch displayRequest()
Thank you in advance