下面列出了怎么用javax.swing.GroupLayout.SequentialGroup的API类实例代码及写法,或者点击链接到github查看源代码。
private void updatePanels() {
jFiltersPanel.removeAll();
GroupLayout groupLayout = new GroupLayout(jFiltersPanel);
jFiltersPanel.setLayout(groupLayout);
groupLayout.setAutoCreateGaps(true);
groupLayout.setAutoCreateContainerGaps(false);
ParallelGroup horizontalGroup = groupLayout.createParallelGroup();
SequentialGroup verticalGroup = groupLayout.createSequentialGroup();
for (LocationPanel locationPanel : locationPanels) {
horizontalGroup.addComponent(locationPanel.getPanel());
verticalGroup.addComponent(locationPanel.getPanel());
}
jFiltersPanel.setVisible(!locationPanels.isEmpty());
groupLayout.setHorizontalGroup(horizontalGroup);
groupLayout.setVerticalGroup(verticalGroup);
autoValidate();
this.getDialog().pack();
}
private void doLayout() {
autoValidate();
jFilters.removeAll();
GroupLayout layout = new GroupLayout(jFilters);
jFilters.setLayout(layout);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(false);
ParallelGroup horizontalGroup = layout.createParallelGroup();
SequentialGroup verticalGroup = layout.createSequentialGroup();
for (FilterPanel ownerPanel : ownerPanels) {
horizontalGroup.addComponent(ownerPanel.getPanel());
verticalGroup.addComponent(ownerPanel.getPanel());
}
for (FilterPanel flagPanel : flagPanels) {
horizontalGroup.addComponent(flagPanel.getPanel());
verticalGroup.addComponent(flagPanel.getPanel());
}
for (FilterPanel containerPanel : containerPanels) {
horizontalGroup.addComponent(containerPanel.getPanel());
verticalGroup.addComponent(containerPanel.getPanel());
}
if (singletonPanel != null) {
horizontalGroup.addComponent(singletonPanel.getPanel());
verticalGroup.addComponent(singletonPanel.getPanel());
}
layout.setVerticalGroup(verticalGroup);
layout.setHorizontalGroup(horizontalGroup);
getDialog().pack();
}
void setLayoutGroups(GroupLayout.ParallelGroup horizontalGroup,
GroupLayout.SequentialGroup verticalGroup) {
this.horizontalGroup = horizontalGroup;
this.verticalGroup = verticalGroup;
}
/**
* Update the controls of the detail panel.
*/
void updateDetails() {
bottomPanel.removeAll();
GroupLayout gl = (GroupLayout)bottomPanel.getLayout();
ParallelGroup c1 = gl.createParallelGroup();
ParallelGroup c2 = gl.createParallelGroup();
SequentialGroup r1 = gl.createSequentialGroup();
c1.addComponent(keyLabel);
c2.addComponent(keyField);
r1.addGroup(
gl.createParallelGroup(Alignment.BASELINE)
.addComponent(keyLabel)
.addComponent(keyField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
);
textAreas.clear();
for (final String lang : context.dataManager().languages()) {
JLabel lbl = new JLabel(lang);
JTextArea ta = new JTextArea();
final CEValueBox<JTextArea> vta = CEValueBox.of("", ta);
vta.validator = new Action1<JTextArea>() {
@Override
public void invoke(JTextArea value) {
validateLabelField(vta);
}
};
textAreas.put(lang, vta);
c1.addComponent(lbl);
c2.addComponent(vta);
r1.addGroup(
gl.createParallelGroup(Alignment.BASELINE)
.addComponent(lbl)
.addComponent(vta, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
);
}
gl.setHorizontalGroup(
gl.createSequentialGroup()
.addGroup(c1)
.addGroup(c2)
);
gl.setVerticalGroup(
r1
);
}
/** @return The referenced main data files panel. */
JPanel createReferencesPanel() {
JPanel p = new JPanel();
GroupLayout gl = new GroupLayout(p);
p.setLayout(gl);
gl.setAutoCreateContainerGaps(true);
gl.setAutoCreateGaps(true);
SequentialGroup rows = gl.createSequentialGroup();
ParallelGroup col1 = gl.createParallelGroup();
ParallelGroup col2 = gl.createParallelGroup();
ParallelGroup col3 = gl.createParallelGroup();
for (String a : ELEMENT_NAMES) {
JLabel indicator = new JLabel();
JLabel caption = new JLabel(get("definition.ref_" + a));
JTextField textField = new JTextField();
indicators.put(a, indicator);
fields.put(a, textField);
ParallelGroup pg = gl.createParallelGroup(Alignment.BASELINE);
col1.addComponent(caption);
col2.addComponent(textField);
col3.addComponent(indicator, 20, 20, 20);
pg.addComponent(caption);
pg.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE);
pg.addComponent(indicator, 20, 20, 20);
rows.addGroup(pg);
}
gl.setHorizontalGroup(
gl.createSequentialGroup()
.addGroup(col1)
.addGroup(col2)
.addGroup(col3)
);
gl.setVerticalGroup(rows);
return p;
}
/**
* @return the properties listing panel
*/
JPanel createPropertiesPanel() {
JPanel p = new JPanel();
GroupLayout gl = new GroupLayout(p);
p.setLayout(gl);
gl.setAutoCreateContainerGaps(true);
gl.setAutoCreateGaps(true);
SequentialGroup rows = gl.createSequentialGroup();
ParallelGroup col1 = gl.createParallelGroup();
ParallelGroup col2 = gl.createParallelGroup();
ParallelGroup col3 = gl.createParallelGroup();
for (String a : PARAM_NAMES) {
JLabel indicator = new JLabel();
JLabel caption = new JLabel(get("definition.refprop_" + a));
JTextField textField = new JTextField(10);
textField.setHorizontalAlignment(JTextField.RIGHT);
caption.setToolTipText(get("definition.refprop_" + a + ".tip"));
textField.setToolTipText(get("definition.refprop_" + a + ".tip"));
indicators.put(a, indicator);
fields.put(a, textField);
ParallelGroup pg = gl.createParallelGroup(Alignment.BASELINE);
col1.addComponent(caption);
col2.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE);
col3.addComponent(indicator, 20, 20, 20);
pg.addComponent(caption);
pg.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE);
pg.addComponent(indicator, 20, 20, 20);
rows.addGroup(pg);
}
gl.setHorizontalGroup(
gl.createSequentialGroup()
.addGroup(col1)
.addGroup(col2)
.addGroup(col3)
);
gl.setVerticalGroup(rows);
return p;
}