2012-12-17 29 views
-2

我在我的一個類中定義了以下襬動佈局,我無法理解發生了什麼。Java:表單佈局參數的解釋

private void initComponents() 
    { 
     locationPanel = new JPanel(); 
     label1 = new JLabel(); 
     lastUpdateLabel = new JLabel(); 
     label2 = new JLabel(); 
     accuracyLabel = new JLabel(); 
     batteryPanel = new JPanel(); 
     batteryLabel = new JLabel(); 
     label3 = new JLabel(); 
     cc = new CellConstraints(); 

     setLayout(new FormLayout("default", "default")); 

     locationPanel.setBorder(new TitledBorder("Info")); 
     locationPanel.setLayout(new FormLayout("right:pref, 6dlu, 50dlu, 4dlu, default", "pref, 3dlu, pref, 3dlu, pref")); 


     label1.setText("Last Update:"); 
     locationPanel.add(label1, cc.xy(1, 1)); 

     lastUpdateLabel.setText("Unknown"); 
     locationPanel.add(lastUpdateLabel, cc.xy(3, 1)); 


     label2.setText("Accuracy:"); 
     locationPanel.add(label2, cc.xy(1, 3)); 

     // ---- accuracyLabel ---- 
     accuracyLabel.setText("Unknown"); 
     locationPanel.add(accuracyLabel, cc.xy(3, 3)); 

     label3.setText("Battery Level"); 
     locationPanel.add(label3, cc.xy(1, 5)); 


     batteryLabel.setText("Unknown"); 
     locationPanel.add(batteryLabel, cc.xy(3, 5)); 

     add(locationPanel, cc.xy(1, 1)); 
    } 

問題:我覺得它的說法應該是3行2列?定義了多少行和列;我將如何製作4 x 2佈局?我如何確定這是什麼話locationPanel.setLayout(new FormLayout("right:pref, 6dlu, 50dlu, 4dlu, default", "pref, 3dlu, pref, 3dlu, pref"));

+1

你的問題是什麼? –

+0

@AleksanderBlomskøld編輯的問題 – stackoverflow

+2

如何閱讀[文檔](http://www.formdev.com/jformdesigner/doc/layouts/formlayout/)? –

回答