我在我的一个类中定义了以下摆动布局,我无法理解发生了什么。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"));
你的问题是什么? –
@AleksanderBlomskøld编辑的问题 – stackoverflow
如何阅读[文档](http://www.formdev.com/jformdesigner/doc/layouts/formlayout/)? –