因為之前學的MFC、BCB都是用拖拉的方式來建立Fram的內容,在上JAVA的時候剛好上到Layout的部份,覺得很有趣,剛好老師又提到BorderLayout的按鈕如果NORTH、WEST、CENTER、EAST、或SOUTH其中之一缺少,其餘的會自動膨脹(實驗證明是錯誤的),但我又不知道他會如何膨脹,所以就做了這個實驗!
首先,先了解31種情形是怎麼來的,(雖然我離散數學很爛,但好歹重修也過了,更何況未來的研究所還要用到,所以這一點點的基本東西我還會。),因為有五種情況:1個Button、2個Button、3個Button、4個Button、和5個Button,加上各種情況又有各自的排列組合,所以所有的情況是C5取1+C5取2+C5取3+C5取4+C5取5=5+10+10+5+1=31種。
接下來,把各種情況列出來:
5個Button(Click)
4個Button(Click)
3個Button(Click)
2個Button(Click)
1個Button(Click)
最後歸納出來,不是只要缺少就會自動膨脹填滿,要他膨脹填滿需要Center的存在。而下面是我歸類所有有Center的狀態,也是比較有可能使用到的膨脹情形:
4個Button:
![](https://pic.pimg.tw/hellolucky/1180016674.png)
![](https://pic.pimg.tw/hellolucky/1180016727.png)
![](https://pic.pimg.tw/hellolucky/1180016805.png)
![](https://pic.pimg.tw/hellolucky/1180016849.png)
3個Button:
![](https://pic.pimg.tw/hellolucky/1180018960.png)
![](https://pic.pimg.tw/hellolucky/1180018961.png)
![](https://pic.pimg.tw/hellolucky/1180018962.png)
![](https://pic.pimg.tw/hellolucky/1180018964.png)
![](https://pic.pimg.tw/hellolucky/1180018967.png)
![](https://pic.pimg.tw/hellolucky/1180018968.png)
2個Button:
![](https://pic.pimg.tw/hellolucky/1180019472.png)
![](https://pic.pimg.tw/hellolucky/1180019473.png)
![](https://pic.pimg.tw/hellolucky/1180019480.png)
![](https://pic.pimg.tw/hellolucky/1180019475.png)
結論,也許有點白痴,但希望可以在需要版面配置的時候,拿來當百科全書來查。
首先,先了解31種情形是怎麼來的,(雖然我離散數學很爛,但好歹重修也過了,更何況未來的研究所還要用到,所以這一點點的基本東西我還會。),因為有五種情況:1個Button、2個Button、3個Button、4個Button、和5個Button,加上各種情況又有各自的排列組合,所以所有的情況是C5取1+C5取2+C5取3+C5取4+C5取5=5+10+10+5+1=31種。
接下來,把各種情況列出來:
5個Button(Click)
4個Button(Click)
3個Button(Click)
2個Button(Click)
1個Button(Click)
最後歸納出來,不是只要缺少就會自動膨脹填滿,要他膨脹填滿需要Center的存在。而下面是我歸類所有有Center的狀態,也是比較有可能使用到的膨脹情形:
4個Button:
![](https://pic.pimg.tw/hellolucky/1180016674.png)
![](https://pic.pimg.tw/hellolucky/1180016727.png)
![](https://pic.pimg.tw/hellolucky/1180016805.png)
![](https://pic.pimg.tw/hellolucky/1180016849.png)
3個Button:
![](https://pic.pimg.tw/hellolucky/1180018960.png)
![](https://pic.pimg.tw/hellolucky/1180018961.png)
![](https://pic.pimg.tw/hellolucky/1180018962.png)
![](https://pic.pimg.tw/hellolucky/1180018964.png)
![](https://pic.pimg.tw/hellolucky/1180018967.png)
![](https://pic.pimg.tw/hellolucky/1180018968.png)
2個Button:
![](https://pic.pimg.tw/hellolucky/1180019472.png)
![](https://pic.pimg.tw/hellolucky/1180019473.png)
![](https://pic.pimg.tw/hellolucky/1180019480.png)
![](https://pic.pimg.tw/hellolucky/1180019475.png)
結論,也許有點白痴,但希望可以在需要版面配置的時候,拿來當百科全書來查。
全站熱搜