Browse Source

New fixed window resize

Veloe 4 years ago
parent
commit
b44f9863e4

BIN
out/production/JavaFxApplication/com/moviesdb/Controller.class


BIN
out/production/JavaFxApplication/com/moviesdb/Movie.class


+ 7 - 14
out/production/JavaFxApplication/com/moviesdb/test2.fxml

@@ -43,11 +43,9 @@
 <?import javafx.scene.control.SplitPane?>
 <?import javafx.scene.control.TextField?>
 <?import javafx.scene.layout.AnchorPane?>
-<?import javafx.scene.layout.ColumnConstraints?>
-<?import javafx.scene.layout.GridPane?>
+<?import javafx.scene.layout.FlowPane?>
 <?import javafx.scene.layout.HBox?>
 <?import javafx.scene.layout.Pane?>
-<?import javafx.scene.layout.RowConstraints?>
 <?import javafx.scene.layout.VBox?>
 <?import javafx.scene.paint.Color?>
 <?import javafx.scene.text.Font?>
@@ -126,22 +124,17 @@
                         <Color red="0.624" green="0.624" blue="0.624" fx:id="x21" />
                      </textFill>
                   </Label>
-                  <ScrollPane fx:id="scrollPane" hbarPolicy="NEVER" layoutX="14.0" layoutY="89.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="400.0" prefHeight="430.0" prefWidth="958.0" style="-fx-background-color: transparent; -fx-border-color: #212121;" vbarPolicy="NEVER" AnchorPane.bottomAnchor="31.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="8.0" AnchorPane.topAnchor="71.0">
+                  <ScrollPane fx:id="scrollPane" fitToWidth="true" fitToHeight="true" hbarPolicy="NEVER" layoutX="14.0" layoutY="89.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="400.0" prefHeight="430.0" prefWidth="958.0" style="-fx-background-color: transparent; -fx-border-color: #212121;" vbarPolicy="NEVER" AnchorPane.bottomAnchor="31.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="8.0" AnchorPane.topAnchor="71.0">
                      <styleClass>
                         <String fx:value="split-pane" />
                         <String fx:value="split-pane-divider" />
                      </styleClass>
                      <content>
-                        <GridPane fx:id="moviesGrid" gridLinesVisible="true" style="-fx-background-color: #212121;">
-                          <columnConstraints>
-                            <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
-                            <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
-                          </columnConstraints>
-                          <rowConstraints>
-                            <RowConstraints maxHeight="268.0" minHeight="10.0" prefHeight="232.0" vgrow="SOMETIMES" />
-                            <RowConstraints maxHeight="267.0" minHeight="10.0" prefHeight="249.0" vgrow="SOMETIMES" />
-                          </rowConstraints>
-                        </GridPane>
+                         <AnchorPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
+                           <children>
+                              <FlowPane fx:id="moviesGrid" prefHeight="448.0" prefWidth="954.0" style="-fx-background-color: #212121;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
+                           </children>
+                         </AnchorPane>
                      </content>
                   </ScrollPane>
                   <Label alignment="CENTER" layoutX="11.0" layoutY="520.0" onMouseClicked="#openFilter" style="&#10;" text="Advanced search?" textAlignment="CENTER" wrapText="false" AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="11.0">

+ 41 - 21
src/com/moviesdb/Controller.java

@@ -9,6 +9,7 @@ import javafx.scene.control.*;
 import javafx.scene.image.Image;
 import javafx.scene.image.ImageView;
 import javafx.scene.layout.AnchorPane;
+import javafx.scene.layout.FlowPane;
 import javafx.scene.layout.GridPane;
 import javafx.scene.layout.Pane;
 import javafx.scene.control.Alert.AlertType;
@@ -30,7 +31,7 @@ public class Controller {
     @FXML
     MenuItem menuNew;
     @FXML
-    GridPane moviesGrid;
+    FlowPane moviesGrid;
     @FXML
     ScrollPane scrollPane;
     @FXML
@@ -41,6 +42,8 @@ public class Controller {
     AnchorPane detailsPicPane;
     @FXML
     AnchorPane filterPane;
+    @FXML
+            Label button;
 
     @FXML
     Label minimizeButton;
@@ -120,10 +123,10 @@ public class Controller {
         moviesGrid.getChildren().clear();
         //moviesGrid.setAlignment(Pos.CENTER);
         //fill grid by movies
-        moviesGrid.addRow(0, labelsMovies[0], labelsMovies[1]);
+        //moviesGrid.addRow(0, labelsMovies[0], labelsMovies[1]);
         //moviesGrid.minHeight(moviesGrid.getMinHeight() + 222);
-        moviesGrid.setPrefWidth(browserPane.getWidth()-26);
-        moviesGrid.setMinHeight(scrollPane.getHeight());
+        //moviesGrid.setPrefWidth(browserPane.getWidth()-26);
+        //moviesGrid.setMinHeight(scrollPane.getHeight());
         gridResize();
         //moviesGrid.setPrefHeight(moviesGrid.getHeight());
 
@@ -175,12 +178,15 @@ public class Controller {
             //movie.
             detailsPicPane.getChildren().add(detailsImage);
             // 300px is details window width
-            scrollPane.setPrefWidth(browserPane.getWidth()-300);
-            scrollPane.setPrefHeight(browserPane.getHeight());
-            moviesGrid.setPrefWidth(browserPane.getWidth() -300);
+            //scrollPane.setPrefWidth(browserPane.getWidth()-300);
+            //scrollPane.setPrefHeight(browserPane.getHeight());
+            //moviesGrid.setPrefWidth(browserPane.getWidth());
             //moviesGrid.setPrefHeight(browserPane.getHeight());
             //loadPosters();
 
+            gridResize();
+            //button.setText(Double.toString(browserPane.getWidth()));
+
         }
         else
         {
@@ -189,10 +195,13 @@ public class Controller {
             detailsPane.setPrefWidth(0);
             detailsPane.setMaxWidth(0);
             // 300px is details window width
-            scrollPane.setPrefWidth(browserPane.getWidth()+300);
-            scrollPane.setPrefHeight(browserPane.getHeight());
-            moviesGrid.setPrefWidth(browserPane.getWidth()+300);
+            //scrollPane.setPrefWidth(browserPane.getWidth()+300);
+            //scrollPane.setPrefHeight(browserPane.getHeight());
+            //moviesGrid.setPrefWidth(scrollPane.getWidth()+300);
             //moviesGrid.setPrefHeight(browserPane.getHeight());
+            //browserPane.setPrefWidth(browserPane.getWidth()+300);
+            gridResize();
+            //button.setText(Double.toString(browserPane.getWidth()));
         }
     }
 
@@ -213,11 +222,11 @@ public class Controller {
             filterPane.setMaxWidth(300);
             //loadPosters();
             // 300px is filter window width
-            scrollPane.setPrefWidth(browserPane.getWidth()-300);
-            scrollPane.setPrefHeight(browserPane.getHeight());
-            moviesGrid.setPrefWidth(browserPane.getWidth() -300);
-            moviesGrid.setPrefHeight(browserPane.getHeight());
-            //gridResize();
+            //scrollPane.setPrefWidth(browserPane.getWidth()-300);
+            //scrollPane.setPrefHeight(browserPane.getHeight());
+            //moviesGrid.setPrefWidth(browserPane.getWidth() -300);
+            //moviesGrid.setPrefHeight(browserPane.getHeight());
+            gridResize();
         }
         else
         {
@@ -226,11 +235,11 @@ public class Controller {
             filterPane.setMaxWidth(0);
             //loadPosters();
             // 300px is filter window width
-            scrollPane.setPrefWidth(browserPane.getWidth()+300);
-            scrollPane.setPrefHeight(browserPane.getHeight());
-            moviesGrid.setPrefWidth(browserPane.getWidth()+300);
-            moviesGrid.setPrefHeight(browserPane.getHeight());
-            //gridResize();
+            //scrollPane.setPrefWidth(browserPane.getWidth()+300);
+            //scrollPane.setPrefHeight(browserPane.getHeight());
+            //moviesGrid.setPrefWidth(scrollPane.getWidth()+300);
+            //moviesGrid.setPrefHeight(browserPane.getHeight());
+            gridResize();
         }
     }
 
@@ -246,13 +255,24 @@ public class Controller {
             moviesGrid.setMinHeight(242*rows);
         moviesGrid.setMaxWidth(scrollPane.getWidth());
         moviesGrid.setPrefWidth(scrollPane.getWidth());
+
+        moviesGrid.setAlignment(Pos.CENTER);
+        moviesGrid.setHgap( 75);
+        moviesGrid.setVgap( 25);
+
         moviesGrid.getChildren().clear();
         int k = 0;
         for(int i = 0; i < rows; i++)
         {
             for (int j = 0; j < cols; j++)
             {
-                moviesGrid.add(labelsMovies[k],j,i);
+                try {
+                    moviesGrid.getChildren().add(labelsMovies[k]);
+                }
+                catch (Exception err)
+                {
+                    k++;
+                }
                 if(k == movies.length - 1)
                     break;
                 k++;

+ 1 - 1
src/com/moviesdb/DataBaseConnector.java

@@ -12,7 +12,7 @@ public class DataBaseConnector {
     public void initConnection(String ui_user, String ui_pass) {
         try {
             // connect way #2
-            String url = "jdbc:mysql://192.168.192.1/moviesdb";
+            String url = "jdbc:mysql://192.168.1.119/moviesdb";
             String user = ui_user;
             String password = ui_pass;
             user = "Veloe";

+ 7 - 14
src/com/moviesdb/test2.fxml

@@ -43,11 +43,9 @@
 <?import javafx.scene.control.SplitPane?>
 <?import javafx.scene.control.TextField?>
 <?import javafx.scene.layout.AnchorPane?>
-<?import javafx.scene.layout.ColumnConstraints?>
-<?import javafx.scene.layout.GridPane?>
+<?import javafx.scene.layout.FlowPane?>
 <?import javafx.scene.layout.HBox?>
 <?import javafx.scene.layout.Pane?>
-<?import javafx.scene.layout.RowConstraints?>
 <?import javafx.scene.layout.VBox?>
 <?import javafx.scene.paint.Color?>
 <?import javafx.scene.text.Font?>
@@ -126,22 +124,17 @@
                         <Color red="0.624" green="0.624" blue="0.624" fx:id="x21" />
                      </textFill>
                   </Label>
-                  <ScrollPane fx:id="scrollPane" hbarPolicy="NEVER" layoutX="14.0" layoutY="89.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="400.0" prefHeight="430.0" prefWidth="958.0" style="-fx-background-color: transparent; -fx-border-color: #212121;" vbarPolicy="NEVER" AnchorPane.bottomAnchor="31.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="8.0" AnchorPane.topAnchor="71.0">
+                  <ScrollPane fx:id="scrollPane" fitToWidth="true" fitToHeight="true" hbarPolicy="NEVER" layoutX="14.0" layoutY="89.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="400.0" prefHeight="430.0" prefWidth="958.0" style="-fx-background-color: transparent; -fx-border-color: #212121;" vbarPolicy="NEVER" AnchorPane.bottomAnchor="31.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="8.0" AnchorPane.topAnchor="71.0">
                      <styleClass>
                         <String fx:value="split-pane" />
                         <String fx:value="split-pane-divider" />
                      </styleClass>
                      <content>
-                        <GridPane fx:id="moviesGrid" gridLinesVisible="true" style="-fx-background-color: #212121;">
-                          <columnConstraints>
-                            <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
-                            <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
-                          </columnConstraints>
-                          <rowConstraints>
-                            <RowConstraints maxHeight="268.0" minHeight="10.0" prefHeight="232.0" vgrow="SOMETIMES" />
-                            <RowConstraints maxHeight="267.0" minHeight="10.0" prefHeight="249.0" vgrow="SOMETIMES" />
-                          </rowConstraints>
-                        </GridPane>
+                         <AnchorPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
+                           <children>
+                              <FlowPane fx:id="moviesGrid" prefHeight="448.0" prefWidth="954.0" style="-fx-background-color: #212121;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
+                           </children>
+                         </AnchorPane>
                      </content>
                   </ScrollPane>
                   <Label alignment="CENTER" layoutX="11.0" layoutY="520.0" onMouseClicked="#openFilter" style="&#10;" text="Advanced search?" textAlignment="CENTER" wrapText="false" AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="11.0">