소스 검색

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
     {