Skip to content

Instantly share code, notes, and snippets.

@busgi busgi/CreateSchemeController Secret
Created Apr 23, 2019

Embed
What would you like to do?
package CreateSchemePackage;
import java.util.List;
import Row.Row;
import ViewAndController.ViewController;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
import model.Model;
public class CreateSchemeController {
List<TextField[]> textFields;
int b = 0;
int columnIndex = 0;
Row row = new Row();
private final Stage primaryStage;
private final CreateSchemeView csv = new CreateSchemeView(this);
public CreateSchemeController(final Stage primaryStage) {
this.primaryStage = primaryStage;
}
public Stage getPrimaryStage() {
return primaryStage;
}
public CreateSchemeView getCreateSchemeView() {
return csv;
}
public void handle(ActionEvent event) {
final Object source = event.getSource();
if (source.equals(csv.getNew())) {
System.out.println("ButtonB has been pressed, switching to ViewC.");
csv.paneEdit.setVisible(true);
}
}
public void plusButtonHandle(ActionEvent event) {
final Object source = event.getSource();
if (source.equals(csv.getPlus())) {
System.out.println("Plus Button wurde gedrückt");
csv.vbox2.setVisible(true);
}
}
public void textFieldButtonHandle(ActionEvent event) {
final Object source = event.getSource();
if (source.equals(csv.getTextFields())) {
csv.hboxEdit.getChildren().addAll(csv.title, csv.description, csv.maxPoints, csv.reachedPoints);
csv.ok.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent e) {
csv.listPane.add(csv.title, 0, b);
csv.listPane.add(csv.description, 1, b);
csv.listPane.add(csv.maxPoints, 2, b);
csv.listPane.add(csv.reachedPoints, 3, b);
textFields.add(new TextField[] { csv.title, csv.description, csv.maxPoints, csv.reachedPoints });
b = b + 1;
}
});
}
}
}
package CreateSchemePackage;
import model.Model;
import ViewAndController.ViewController;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonBase;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.MenuItem;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.control.Tooltip;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class CreateSchemeView extends VBox {
private final Button view = new Button("View");
TabPane tabPane = new TabPane();
Tab tab2 = new Tab("Code");
Tab tab1 = new Tab("Bewertung");
TextArea textarea = new TextArea();
GridPane grid = new GridPane();
Pane pane = new Pane();
Pane paneEdit = new Pane();
GridPane listPane = new GridPane();
VBox vbox = new VBox();
VBox vbox2 = new VBox();
HBox hbox = new HBox();
HBox hboxEdit = new HBox();
TextField title = new TextField();
TextField description = new TextField();
TextField maxPoints = new TextField();
TextField reachedPoints = new TextField();
Label label = new Label("Bewertungsschema erstellen: ");
Button button = new Button("New");
Button plus = new Button("+");
Button ok = new Button ("Okay");
Button createTextField = new Button("Add TextFields");
Label text = new Label(" ");
Button addButton = new Button("Erstellen");
Button cancelButton = new Button("Abbrechen");
Button saveButton = new Button("Speichern");
Button addTextFieldButton = new Button("+");
Region region = new Region();
MenuItem item1 = new MenuItem("Tooltip erstellen");
private Pane root;
VBox vbox3 = new VBox();
private Tooltip tooltip = new Tooltip();
TableCell<Model, String> cell = new TableCell<Model, String>();
public CreateSchemeView(final CreateSchemeController createSchemeController) {
initCreateScheme();
button.setOnAction(createSchemeController::handle);
plus.setOnAction(createSchemeController::plusButtonHandle);
ok.setOnAction(createSchemeController::plusButtonHandle);
createTextField.setOnAction(createSchemeController::textFieldButtonHandle);
view.setOnAction(event -> {
System.out.println("ButtonB has been pressed, switching to ViewA.");
final Stage primaryStage = createSchemeController.getPrimaryStage();
final ViewController viewController = new ViewController(primaryStage);
final Scene scene = new Scene(viewController.getView(),250,600);
primaryStage.setScene(scene);
});
}
public void initCreateScheme(){
view.setLayoutX(0);
view.setLayoutY(0);
tab2.setContent(textarea);
tab1.setContent(pane);
pane.setStyle("-fx-background-color:rgb(217, 217, 217)");
ok.setDisable(false);
hboxEdit.getChildren().addAll(createTextField);
hboxEdit.getChildren().add(ok);
hboxEdit.setPadding(new Insets(20,20,20,20));
hboxEdit.setSpacing(20);
hboxEdit.setStyle("-fx-background-color:rgb(230,230,230,230)");
paneEdit.setVisible(false);
paneEdit.getChildren().add(hboxEdit);
tabPane.setPadding(new Insets(20,20,20,20));
tabPane.getTabs().addAll(tab1, tab2);
tabPane.setLayoutY(80.0);
tabPane.setLayoutY(5.0);
tabPane.setMaxWidth(1200.0);
tabPane.setMaxHeight(550.0);
textarea.setPrefHeight(450.0);
vbox2.setVisible(false);
text.setLayoutX(300.0);
text.setLayoutY(42.0);
hbox.setSpacing(10.0);
hbox.getChildren().addAll(button, plus);
vbox.setLayoutX(10.0);
vbox.setLayoutY(30.0);
vbox.setSpacing(30.0);
vbox.getChildren().addAll(label, hbox);
listPane.setPrefWidth(800);
listPane.setHgap(20);
vbox2.setLayoutX(300.0);
vbox2.setLayoutY(30.0);
vbox2.setSpacing(10.0);
vbox2.setMaxHeight(900.0);
vbox2.setPrefWidth(1000.0);
vbox2.getChildren().add(listPane);
vbox2.getChildren().add(region);
pane.getChildren().addAll(vbox,vbox2);
this.getChildren().addAll(view, tabPane, paneEdit);
}
public Button getCreateSchemeView() {
return view;
}
public Button getNew() {
return button;
}
public Button getPlus() {
return plus;
}
public Button getTextFields() {
return createTextField;
}
public Button getOK() {
return ok;
}
public TextField getTitle() {
return title;
}
public TextField getDescription() {
return title;
}
public TextField getMaxPoints() {
return title;
}
public TextField getReachedPoints() {
return title;
}
}
package Row;
import javafx.beans.property.SimpleSetProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
public class Model {
private String title;
private String description;
private String maxPoints;
private String reachedPoints;
public Model() {}
public Model(String title, String description, String maxPoints, String reachedPoints) {
this.title = title;
this.description = description;
this.maxPoints = maxPoints;
this.reachedPoints = reachedPoints;
}
public String getTitle() {
return title;
}
public String getDescription() {
return description;
}
public String getMaxPoints() {
return maxPoints;
}
public String getReachedPoints() {
return reachedPoints;
}
public String toString()
{
return title + " " + description + " " + maxPoints + " " + reachedPoints;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.