TestFreundebuch

This commit is contained in:
John-Hendrik Hugo 2021-11-15 10:46:53 +01:00
parent c2105f9a6d
commit aa038cc036
21 changed files with 826 additions and 0 deletions

25
.gitignore vendored Normal file
View File

@ -0,0 +1,25 @@
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
#Quelle: https://github.com/github/gitignore/blob/master/Java.gitignore

3
DigitalesFreundebuch/.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

23
DigitalesFreundebuch/.idea/compiler.xml generated Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>

View File

@ -0,0 +1,2 @@
<html>Simple <b>JavaFX 2.0</b> application that includes simple .fxml file with attached controller and Main class to quick start. Artifact to build JavaFX application is provided.
</html>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

4
DigitalesFreundebuch/.idea/gradle.xml generated Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
</project>

9
DigitalesFreundebuch/.idea/misc.xml generated Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectKey">
<option name="state" value="project://e79810c8-c5c8-43b1-b19c-90c1f4095425" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
DigitalesFreundebuch/.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/DigitalesFreundebuch.iml" filepath="$PROJECT_DIR$/DigitalesFreundebuch.iml" />
</modules>
</component>
</project>

125
DigitalesFreundebuch/.idea/uiDesigner.xml generated Normal file
View File

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

7
DigitalesFreundebuch/.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
</component>
</project>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/src/sample/sqlite-jdbc-3.36.0.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,8 @@
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<GridPane fx:controller="sample.Controller"
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
</GridPane>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@ -0,0 +1,4 @@
package sample;
public class Controller {
}

View File

@ -0,0 +1,570 @@
package sample;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ColorPicker;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.effect.DropShadow;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.TextAlignment;
import javafx.stage.Stage;
import java.sql.*;
public class Main extends Application {
// Datenbankvariablen
@Override
public void start(Stage primaryStage) throws Exception{
// Layout / Scene
VBox root = new VBox();
Scene scene = new Scene(root, 300,400);
scene.getStylesheets().add("sample/application.css");
root.setSpacing(15.0);
// Titel
primaryStage.setTitle("Freundebuch");
// Shadow
DropShadow shadow = new DropShadow();
// Label
Label labelMenue = new Label ("Mein digitales\nFreundebuch");
// Label designen
labelMenue.setPadding(new Insets(10));
labelMenue.setTextAlignment(TextAlignment.CENTER);
labelMenue.setFont(new Font("Comic Sans MS", 30));
// Button
Button freundeAnzeigen = new Button("Freunde zeigen");
Button freundeHinzufuegen = new Button("Freunde hinzufügen");
Button freundeSuchen = new Button("Freunde suchen");
// Button designen
freundeAnzeigen.setPadding(new Insets(10));
freundeHinzufuegen.setPadding(new Insets(10));
freundeSuchen.setPadding(new Insets(10));
freundeAnzeigen.setMinSize(150.0, 50.0);
freundeHinzufuegen.setMinSize(150.0, 50.0);
freundeSuchen.setMinSize(150.0, 50.0);
freundeAnzeigen.setFont(Font.font("Comic Sans MS"));
freundeHinzufuegen.setFont(Font.font("Comic Sans MS"));
freundeSuchen.setFont(Font.font("Comic Sans MS"));
// ---------------------------------------------------------------------------------------------------------------------------------------------
// Freunde Anzeigen Button
freundeAnzeigen.setOnMouseEntered(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
freundeAnzeigen.setEffect(shadow);
}
});
freundeAnzeigen.setOnMouseExited(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
freundeAnzeigen.setEffect(null);
}
});
freundeAnzeigen.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
// Layout / Scene
GridPane root2 = new GridPane();
Scene scene2 = new Scene(root2, 800,500);
// Ins Layout einfügen
// Stage
primaryStage.setScene(scene2);
primaryStage.setFullScreen(true);
primaryStage.show();
}
});
// ---------------------------------------------------------------------------------------------------------------------------------------------
// Freunde Hinzufügen Button
freundeHinzufuegen.setOnMouseEntered(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
freundeHinzufuegen.setEffect(shadow);
}
});
freundeHinzufuegen.setOnMouseExited(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
freundeHinzufuegen.setEffect(null);
}
});
freundeHinzufuegen.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
// Layout / Scene
StackPane rahmen = new StackPane();
rahmen.setStyle("-fx-background-color: white;");
HBox root3 = new HBox();
Scene scene3 = new Scene(rahmen, 800,500);
VBox seiteLinks = new VBox();
VBox seiteRechts = new VBox();
seiteLinks.setStyle("-fx-background-color: transparent;");
seiteRechts.setStyle("-fx-background-color: transparent;");
// Rahmen ############################################################
// Rechteck
Rectangle rand = new Rectangle();
rand.setHeight(950);
rand.setWidth(1650);
rand.setFill(Color.TRANSPARENT);
rand.setStroke(Color.WHITE);
rand.setStrokeWidth(5);
// Seite Links ############################################################
// Image
Image img = new Image("sample/bildIcon.jpg");
ImageView view = new ImageView(img);
view.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
// File Chooser
}
});
// Rechteck
Rectangle viereck = new Rectangle();
viereck.setHeight(250);
viereck.setWidth(200);
viereck.setFill(Color.TRANSPARENT);
viereck.setStroke(Color.BLACK);
viereck.setStrokeWidth(5);
// StackPane
StackPane stackPane = new StackPane();
// In StackPane hinzufügen
stackPane.getChildren().addAll(viereck, view);
stackPane.setMaxHeight(250);
stackPane.setMaxWidth(200);
// VBoxen
VBox grundedatenRechts = new VBox();
// HBoxen
HBox grunddaten = new HBox();
HBox vornameBox = new HBox();
HBox nachnameBox = new HBox();
HBox geburtstagBox = new HBox();
HBox wohnortBox = new HBox();
HBox spitznameBox = new HBox();
HBox lieblingsfarbeBox = new HBox();
HBox lieblingsessenBox = new HBox();
HBox lieblingstierBox = new HBox();
HBox hobbysBox = new HBox();
// Circle
HBox kreisPosi = new HBox();
Circle circle = new Circle();
circle.setRadius(20);
circle.setFill(Color.WHITE);
kreisPosi.getChildren().add(circle);
kreisPosi.setPadding(new Insets(0,0,0,110));
// Button Effekte
view.setOnMouseEntered(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
view.setEffect(shadow);
}
});
view.setOnMouseExited(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
view.setEffect(null);
}
});
// Button Klick
view.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
// Hier soll sich ein Dateiauswahlfenster öffnen wo das Bild ausgewählt werden kann
}
});
// ColorPicker
ColorPicker colorPicker = new ColorPicker();
// ColorPicker EventHandler
colorPicker.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
// hier muss irgendwie der Rand gefärbt werden in Farbe des Color Picker
viereck.setStroke(colorPicker.getValue());
rand.setStroke(colorPicker.getValue());
circle.setFill(colorPicker.getValue());
}
});
// Label
Label vornameLabel = new Label("Vorname");
Label nachnameLabel = new Label("Nachname");
Label geburtstagLabel = new Label("Geburtstag");
Label wohnortLabel = new Label("Wohnort");
Label spitznameLabel = new Label("Spitzname");
Label lieblingsfarbeLabel = new Label("Lieblingsfarbe");
Label lieblingsessenLabel = new Label("Lieblingsessen");
Label lieblingstierLabel = new Label("Lieblingstier");
Label hobbysLabel = new Label("Hobbys");
// Label Positionierung
vornameLabel.setPadding(new Insets(0, 69, 0, 0));
nachnameLabel.setPadding(new Insets(0, 54, 0, 0));
geburtstagLabel.setPadding(new Insets(0, 45, 0, 0));
wohnortLabel.setPadding(new Insets(0, 67, 0, 0));
spitznameLabel.setPadding(new Insets(0, 107, 0, 0));
lieblingsfarbeLabel.setPadding(new Insets(0, 71, 0, 0));
lieblingsessenLabel.setPadding(new Insets(0, 71, 0, 0));
lieblingstierLabel.setPadding(new Insets(0, 88, 0, 0));
hobbysLabel.setPadding(new Insets(0, 135, 0, 0));
// Label Schriftart / Schriftgröße
vornameLabel.setFont(new Font("Comic Sans MS", 20));
nachnameLabel.setFont(new Font("Comic Sans MS", 20));
geburtstagLabel.setFont(new Font("Comic Sans MS", 20));
wohnortLabel.setFont(new Font("Comic Sans MS", 20));
spitznameLabel.setFont(new Font("Comic Sans MS", 20));
lieblingsfarbeLabel.setFont(new Font("Comic Sans MS", 20));
lieblingsessenLabel.setFont(new Font("Comic Sans MS", 20));
lieblingstierLabel.setFont(new Font("Comic Sans MS", 20));
hobbysLabel.setFont(new Font("Comic Sans MS", 20));
// TextField
TextField vorname = new TextField();
TextField nachname = new TextField();
TextField geburtstag = new TextField();
TextField wohnort = new TextField();
TextField spitzname = new TextField();
TextField lieblingsessen = new TextField();
TextField lieblingstier = new TextField();
TextField hobbys = new TextField();
// TextField Größen
vorname.setMinHeight(30);
vorname.setMinWidth(200);
nachname.setMinHeight(30);
nachname.setMinWidth(200);
geburtstag.setMinHeight(30);
geburtstag.setMinWidth(200);
wohnort.setMinHeight(30);
wohnort.setMinWidth(200);
spitzname.setMinHeight(30);
spitzname.setMinWidth(400);
lieblingsessen.setMinHeight(30);
lieblingsessen.setMinWidth(400);
lieblingstier.setMinHeight(30);
lieblingstier.setMinWidth(400);
hobbys.setMinHeight(60);
hobbys.setMinWidth(400);
// In vornameBox, nachnameBox, geburtstagBox, wohnortBox, spitznameBox, lieblingsfarbeBox, lieblingsessenBox, lieblingstierBox, hobbysBox hinzu
vornameBox.getChildren().addAll(vornameLabel, vorname);
nachnameBox.getChildren().addAll(nachnameLabel, nachname);
geburtstagBox.getChildren().addAll(geburtstagLabel, geburtstag);
wohnortBox.getChildren().addAll(wohnortLabel, wohnort);
spitznameBox.getChildren().addAll(spitznameLabel, spitzname);
lieblingsfarbeBox.getChildren().addAll(lieblingsfarbeLabel, colorPicker, kreisPosi); // lieblingsfarbe
lieblingsfarbeBox.setAlignment(Pos.CENTER_LEFT);
lieblingsessenBox.getChildren().addAll(lieblingsessenLabel, lieblingsessen);
lieblingstierBox.getChildren().addAll(lieblingstierLabel, lieblingstier);
hobbysBox.getChildren().addAll(hobbysLabel, hobbys);
// In VBox grunddatenRechts hinzu
grundedatenRechts.getChildren().addAll(vornameBox, nachnameBox, geburtstagBox, wohnortBox);
grundedatenRechts.setAlignment(Pos.CENTER);
grundedatenRechts.setSpacing(35);
grundedatenRechts.setPadding(new Insets(50));
// In HBox Grunddaten hinzu
grunddaten.getChildren().addAll(stackPane, grundedatenRechts);
grunddaten.setAlignment(Pos.CENTER_LEFT);
// In VBox seiteLinks hinzu
seiteLinks.getChildren().addAll(grunddaten, spitznameBox, lieblingsfarbeBox, lieblingsessenBox, lieblingstierBox, hobbysBox);
seiteLinks.setSpacing(35);
// Seite Rechts ############################################################
// HBoxen
HBox lieblingsmusikBox = new HBox();
HBox lieblingsfilmBox = new HBox();
HBox traumautoBox = new HBox();
HBox traumberufBox = new HBox();
HBox likeYouBox = new HBox();
HBox tellMeBox = new HBox();
HBox buttonAuswahl = new HBox();
// Label
Label lieblingsmusikLabel = new Label("Lieblingsmusik");
Label lieblingsfilmLabel = new Label("Lieblingsfilm");
Label traumautoLabel = new Label("Traumauto");
Label traumberufLabel =new Label("Traumberuf");
Label likeYouLabel = new Label("Das mag ich\nan dir");
Label tellMeLabel = new Label("Das wolle\nich dir immer\nschon sagen");
// Label Schriftart / Schriftgröße
lieblingsmusikLabel.setFont(new Font("Comic Sans MS", 20));
lieblingsfilmLabel.setFont(new Font("Comic Sans MS", 20));
traumautoLabel.setFont(new Font("Comic Sans MS", 20));
traumberufLabel.setFont(new Font("Comic Sans MS", 20));
likeYouLabel.setFont(new Font("Comic Sans MS", 20));
tellMeLabel.setFont(new Font("Comic Sans MS", 20));
// TextFields
TextField lieblingsmusik = new TextField();
TextField lieblingsfilm = new TextField();
TextField traumauto = new TextField();
TextField traumberuf = new TextField();
TextField likeYou = new TextField();
TextField tellMe = new TextField();
lieblingsmusik.setMinHeight(30);
lieblingsmusik.setMinWidth(400);
lieblingsfilm.setMinHeight(30);
lieblingsfilm.setMinWidth(400);
traumauto.setMinHeight(30);
traumauto.setMinWidth(400);
traumberuf.setMinHeight(30);
traumberuf.setMinWidth(400);
likeYou.setMinHeight(100);
likeYou.setMinWidth(400);
tellMe.setMinHeight(190);
tellMe.setMinWidth(400);
// Button
Button speichern = new Button("Speichern");
Button abbruch = new Button("Abbruch");
buttonAuswahl.setSpacing(10.0);
buttonAuswahl.setAlignment(Pos.CENTER_RIGHT);
// Button Interaktion
speichern.setOnMouseEntered(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
speichern.setEffect(shadow);
}
});
speichern.setOnMouseExited(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
speichern.setEffect(null);
}
});
speichern.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
}
});
abbruch.setOnMouseEntered(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
abbruch.setEffect(shadow);
}
});
abbruch.setOnMouseExited(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
abbruch.setEffect(null);
}
});
abbruch.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
primaryStage.setScene(scene);
primaryStage.show();
}
});
// Label und TextField Positionierung
lieblingsmusikLabel.setPadding(new Insets(0, 54, 0, 0));
lieblingsfilmLabel.setPadding(new Insets(0, 69, 0, 0));
traumautoLabel.setPadding(new Insets(0, 88, 0, 0));
traumberufLabel.setPadding(new Insets(0, 75, 0, 0));
likeYouLabel.setPadding(new Insets(0, 77, 0, 0));
tellMeLabel.setPadding(new Insets(0, 64, 0, 0));
// HBoxen positionieren
likeYouBox.setPadding(new Insets(50,0,0,0));
likeYouBox.setAlignment(Pos.CENTER_LEFT);
tellMeBox.setPadding(new Insets(5,0,0,0));
tellMeBox.setAlignment(Pos.CENTER_LEFT);
// In HBoxen hinzu
lieblingsmusikBox.getChildren().addAll(lieblingsmusikLabel, lieblingsmusik);
lieblingsfilmBox.getChildren().addAll(lieblingsfilmLabel, lieblingsfilm);
traumautoBox.getChildren().addAll(traumautoLabel, traumauto);
traumberufBox.getChildren().addAll(traumberufLabel, traumberuf);
likeYouBox.getChildren().addAll(likeYouLabel, likeYou);
tellMeBox.getChildren().addAll(tellMeLabel, tellMe);
buttonAuswahl.getChildren().addAll(speichern, abbruch);
// In Seite Rechts hinzu
seiteRechts.getChildren().addAll(lieblingsmusikBox, lieblingsfilmBox, traumautoBox, traumberufBox, likeYouBox, tellMeBox, buttonAuswahl);
seiteRechts.setSpacing(35);
seiteRechts.setPadding(new Insets(50,0,0,0));
// Layout ##################################################################
// Ins Layout einfügen
root3.getChildren().addAll(seiteLinks, seiteRechts);
root3.setPadding(new Insets(150));
root3.setSpacing(150);
root3.setAlignment(Pos.CENTER);
root3.setStyle("-fx-background-color: transparent;");
rahmen.getChildren().addAll(rand, root3);
// Stage
primaryStage.setScene(scene3);
primaryStage.setFullScreen(true);
primaryStage.show();
}
});
// ---------------------------------------------------------------------------------------------------------------------------------------------
// Freunde Suchen Button
freundeSuchen.setOnMouseEntered(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
freundeSuchen.setEffect(shadow);
}
});
freundeSuchen.setOnMouseExited(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
freundeSuchen.setEffect(null);
}
});
freundeSuchen.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
// Layout / Scene
VBox root4 = new VBox();
HBox hBox = new HBox();
Scene scene4 = new Scene(root4, 250,250);
// Label
Label nameLabel = new Label("Vorname:");
nameLabel.setFont(new Font("Comic Sans MS", 15));
nameLabel.setStyle("-fx-font-weight: bold;");
// TextField
TextField freundSuche = new TextField();
freundSuche.setMaxWidth(130.0);
freundSuche.setAlignment(Pos.CENTER);
// Button
Button suche = new Button("Suche");
Button zurueck = new Button("Zurück");
suche.setMinWidth(60.0);
zurueck.setMinWidth(60.0);
// Suchen Button Hover
suche.setOnMouseEntered(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
suche.setEffect(shadow);
}
});
suche.setOnMouseExited(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
suche.setEffect(null);
}
});
// Zurück Button Hover
zurueck.setOnMouseEntered(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
zurueck.setEffect(shadow);
}
});
zurueck.setOnMouseExited(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
zurueck.setEffect(null);
}
});
// Suche Button Click
suche.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
if (freundSuche.getText().isEmpty()) {
freundSuche.setStyle("-fx-border-color: red;");
}
}
});
// Zurück Button Click
zurueck.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
primaryStage.setScene(scene);
primaryStage.setResizable(true);
primaryStage.show();
}
});
// Ins Layout einfügen
hBox.getChildren().addAll(suche, zurueck);
hBox.setAlignment(Pos.CENTER);
hBox.setSpacing(10.0);
root4.getChildren().addAll(nameLabel, freundSuche, hBox);
root4.setAlignment(Pos.CENTER);
root4.setSpacing(15.0);
root4.setStyle("-fx-background-image: url(\"/sample/sucheBackground.jpg\");" +
"-fx-background-repeat: no-repeat;");
// Stage
primaryStage.setScene(scene4);
primaryStage.setResizable(false);
primaryStage.show();
}
});
// Ins Layout einfügen
root.setAlignment(Pos.CENTER);
root.getChildren().addAll(labelMenue, freundeAnzeigen, freundeHinzufuegen, freundeSuchen);
// Stage
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}

View File

@ -0,0 +1,2 @@
.root {
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,8 @@
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<GridPane fx:controller="sample.Controller"
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
</GridPane>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB