我一直在網上尋找直接的答案,但找不到具體的答案。如果這是一個基本問題,道歉,我希望有人能夠幫助解釋一個例子。BorderLayout的參數意味着什麼?
從本質上講,我想知道下面兩行代碼之間的區別:
JPanel panel1 = new JPanel(new BorderLayout(4,4));
JPanel panel2 = new JPanel(new BorderLayout(3,3));
任何幫助或指導將不勝感激。
由於
我一直在網上尋找直接的答案,但找不到具體的答案。如果這是一個基本問題,道歉,我希望有人能夠幫助解釋一個例子。BorderLayout的參數意味着什麼?
從本質上講,我想知道下面兩行代碼之間的區別:
JPanel panel1 = new JPanel(new BorderLayout(4,4));
JPanel panel2 = new JPanel(new BorderLayout(3,3));
任何幫助或指導將不勝感激。
由於
的BorderLayout的構造函數的第一個參數是水平間隙,第二個是垂直間隙。
檢查本教程如何使用BorderLayout的更多信息:http://docs.oracle.com/javase/tutorial/uiswing/layout/border.html
您也應該檢查文檔的詳細信息有關的BorderLayout: http://docs.oracle.com/javase/7/docs/api/java/awt/BorderLayout.html
最佳回答這樣的問題的地方是文檔。你知道在哪裏可以找到它嗎? – 2014-09-05 16:42:29
是的,我這樣做,我一直在尋找,但似乎無法找到直接的答案 – David222 2014-09-05 16:43:39
我不認爲你這樣做。當我說文檔時,我的意思是Java SE api文檔,可以在這裏找到(http://docs.oracle.com/javase/8/docs/api/index.html)。搜索BorderLayout,你會發現['BorderLayout(int hgap,int vgap)'](http://docs.oracle.com/javase/7/docs/api/java/awt/BorderLayout.html#BorderLayout% 28int,%20int%29)構造函數。學習閱讀api文檔是你必須學習的東西。 – 2014-09-05 16:47:25