Explorar o código

no more flow :(

tarfeef101 %!s(int64=6) %!d(string=hai) anos
pai
achega
1b0e0fb7b4
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      assignments/a3/src/main/java/Gallery.java

+ 8 - 1
assignments/a3/src/main/java/Gallery.java

@@ -68,7 +68,14 @@ public class Gallery extends JPanel implements Observer, Serializable
   {
     if (model.getGrid())
     {
-      this.setLayout(new FlowLayout(10));
+      int unit = 200;
+      int total = this.getWidth();
+      if (items.size() > 0)
+      {
+        int unit = items.get(i).getWidth();
+      }
+      int cols = total / unit;
+      this.setLayout(new GridLayout(0, cols));
     }
     else
     {