看板 java 關於我們 聯絡資訊
※ 引述《bypang (第一次上ptt)》之銘言: : 各位大大好 : 小弟最近在學習java,然而卻卡在layout上 : 我想要把JLabel分佈在一個panel上(label的size大小固定) : 一個row可容納8個label,每個label按照順序, : 有點類似Nautilus或My Computer的排序 : 如圖(x代表JLabel) : ______________________ : | x x x x x x x | : | x x x x x x x | : | x | : | | : | | : | | : | | : | | : |_____________________| : 如果使用GridLayout,會變成 : ______________________ : | | : | x x x x x x x | : | | : | | : | x x x x x x x | : | | : | | : | x | : |_____________________| : 請問要怎麼修改,還是要選擇其他的layout? : 謝謝 忘記有沒有更簡單的作法了 很少用Java的Layout - -a 我所想到最簡單的解法 假設你的panel是container 在container上疊加一個subpanel(JPanel), 採用GirdLayout並設定好大小(setBound),再疊到你顯示的大panel上。 container layout設null ; container.add(subpanel); -- I am a person, and I am always thinking . Thinking in love , Thinking in life , Thinking in why , Thinking in worth. I can't believe any of what , I am just thinking then thinking , but worst of all , most of mine is thinking not actioning... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.134.27.68