فهرست منبع

no more flow :(

tarfeef101 6 سال پیش
والد
کامیت
1b0e0fb7b4
1فایلهای تغییر یافته به همراه8 افزوده شده و 1 حذف شده
  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
     {