下面列出了javax.swing.GroupLayout#createParallelGroup ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private GroupLayout.ParallelGroup getVerticalGroup (GroupLayout layout, boolean hasPrimary, boolean hasRequired) {
GroupLayout.ParallelGroup res = layout.createParallelGroup (/* XXX huh? GroupLayout.PREFERRED_SIZE*/);
GroupLayout.SequentialGroup seq = layout.createSequentialGroup ();
if (hasPrimary) {
seq.addComponent (tpPrimaryTitle, GroupLayout.DEFAULT_SIZE, 40, 40)
.addPreferredGap (LayoutStyle.ComponentPlacement.RELATED)
.addComponent (tpPrimaryPlugins, GroupLayout.PREFERRED_SIZE, tpPrimaryPlugins.getPreferredSize ().height, GroupLayout.PREFERRED_SIZE)
.addPreferredGap (LayoutStyle.ComponentPlacement.RELATED)
.addGap (0, 30, 30);
}
if (hasRequired) {
seq.addComponent (tpDependingTitle, GroupLayout.DEFAULT_SIZE, 80, 80)
.addPreferredGap (LayoutStyle.ComponentPlacement.RELATED)
.addComponent (tpDependingPlugins, GroupLayout.PREFERRED_SIZE, tpDependingPlugins.getPreferredSize ().height, GroupLayout.PREFERRED_SIZE)
.addPreferredGap (LayoutStyle.ComponentPlacement.RELATED);
}
res.addGroup (seq);
return res;
}
private GroupLayout.ParallelGroup getHorizontalGroup (GroupLayout layout, boolean hasPrimary, boolean hasRequired) {
GroupLayout.ParallelGroup res = layout.createParallelGroup (Alignment.LEADING);
if (hasPrimary) {
res.addGroup (Alignment.TRAILING, layout.createSequentialGroup ()
.addGroup (layout.createParallelGroup (Alignment.TRAILING)
.addGroup (Alignment.LEADING, layout.createSequentialGroup ()
.addGap (49, 49, 49)
.addComponent (tpPrimaryPlugins, GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE))
.addGroup (Alignment.LEADING, layout.createSequentialGroup ()
.addContainerGap ()
.addComponent (tpPrimaryTitle, GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)))
.addContainerGap ());
}
if (hasRequired) {
res.addGroup (Alignment.TRAILING, layout.createSequentialGroup ()
.addGroup (layout.createParallelGroup (Alignment.TRAILING)
.addGroup (Alignment.LEADING, layout.createSequentialGroup ()
.addGap (49, 49, 49)
.addComponent (tpDependingPlugins, GroupLayout.DEFAULT_SIZE, 403, Short.MAX_VALUE))
.addGroup (Alignment.LEADING, layout.createSequentialGroup ()
.addContainerGap ()
.addComponent (tpDependingTitle, GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)))
.addContainerGap ());
}
return res;
}
private void init() {
errorLabel.setText(" "); // NOI18N
GroupLayout containerPanelLayout = new GroupLayout(containerPanel);
containerPanel.setLayout(containerPanelLayout);
GroupLayout.ParallelGroup horizontalGroup = containerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING);
GroupLayout.SequentialGroup verticalGroup = containerPanelLayout.createSequentialGroup();
containerPanelLayout.setHorizontalGroup(horizontalGroup);
containerPanelLayout.setVerticalGroup(
containerPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(verticalGroup)
);
for (CssPreprocessorUIImplementation.Options options : allOptions) {
JComponent component = options.getComponent();
Parameters.notNull("component", component); // NOI18N
horizontalGroup.addComponent(component, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE);
verticalGroup.addComponent(component, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED);
}
}
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();
}
public ActionsBuilder (JPanel panel, FocusListener listener) {
this.focusListener = listener;
panel.removeAll();
GroupLayout layout = (GroupLayout) panel.getLayout();
horizontalSeqGroup = layout.createSequentialGroup();
layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(horizontalSeqGroup)
);
verticalParallelGroup = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(verticalParallelGroup)
);
}
public ActionsBuilder (JPanel panel) {
panel.removeAll();
GroupLayout layout = (GroupLayout) panel.getLayout();
horizontalSeqGroup = layout.createSequentialGroup();
layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(horizontalSeqGroup)
);
verticalParallelGroup = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(verticalParallelGroup)
);
}
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();
}
/**
* Creates a JPanel with the specified options. Interal use only.
*
* @param opts the options
* @return a jpanel
*/
private static JPanel optionsPanel(final List<Option> opts) {
final JPanel options = new JPanel();
final GroupLayout gl = new GroupLayout(options);
options.setLayout(gl);
gl.setAutoCreateGaps(true);
gl.setAutoCreateContainerGaps(true);
final GroupLayout.ParallelGroup labels = gl.createParallelGroup();
final GroupLayout.ParallelGroup values = gl.createParallelGroup();
final GroupLayout.ParallelGroup titles = gl.createParallelGroup();
final GroupLayout.ParallelGroup horiz = gl.createParallelGroup();
final GroupLayout.SequentialGroup cols = gl.createSequentialGroup();
final GroupLayout.SequentialGroup rows = gl.createSequentialGroup();
cols.addGroup(labels);
cols.addGroup(values);
horiz.addGroup(cols);
horiz.addGroup(titles);
for (final Option o : opts) {
final JLabel l = o.getLabel();
final JComponent c = o.getComponent();
if (c == null) {
// This is a label-only row, allowed to take up the whole row
titles.addComponent(l);
rows.addComponent(l);
} else {
if (l.getBorder() == null) {
l.setBorder(new EmptyBorder(3, 0, 0, 0));
}
if (l.getLabelFor() == null) {
l.setLabelFor(c);
}
labels.addComponent(l);
values.addComponent(c);
final GroupLayout.ParallelGroup row = gl.createParallelGroup(GroupLayout.Alignment.BASELINE);
row.addComponent(l);
row.addComponent(c);
rows.addGroup(row);
}
}
gl.setHorizontalGroup(horiz);
gl.setVerticalGroup(rows);
return options;
}
@Override
protected Group createParallelGroup(GroupLayout layout) {
return layout.createParallelGroup();
}
@Override
protected Group createParallelGroup(GroupLayout layout) {
return layout.createParallelGroup(
GroupLayout.Alignment.LEADING, false);
}
@NbBundle.Messages("CustomizerTesting.testingProviders.noneInstalled=No PHP testing provider found, install one via Plugins (e.g. PHPUnit).")
private void initProvidersPanel() {
List<PhpTestingProvider> allTestingProviders = PhpTesting.getTestingProviders();
if (allTestingProviders.isEmpty()) {
category.setErrorMessage(Bundle.CustomizerTesting_testingProviders_noneInstalled());
category.setValid(true);
return;
}
List<String> currentTestingProviders = uiProps.getTestingProviders();
GroupLayout providersPanelLayout = new GroupLayout(providersPanel);
GroupLayout.ParallelGroup horizontalGroup = providersPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING);
GroupLayout.SequentialGroup verticalGroup = providersPanelLayout.createSequentialGroup();
boolean first = true;
final Collator collator = Collator.getInstance();
Collections.sort(allTestingProviders, new Comparator<PhpTestingProvider>() {
@Override
public int compare(PhpTestingProvider provider1, PhpTestingProvider provider2) {
return collator.compare(provider1.getDisplayName(), provider2.getDisplayName());
}
});
for (PhpTestingProvider testingProvider : allTestingProviders) {
String identifier = testingProvider.getIdentifier();
JCheckBox checkBox = new JCheckBox(testingProvider.getDisplayName());
checkBox.addItemListener(new TestingProviderListener(identifier));
if (currentTestingProviders.contains(identifier)) {
checkBox.setSelected(true);
}
horizontalGroup.addComponent(checkBox);
verticalGroup.addComponent(checkBox);
if (first) {
first = false;
} else {
verticalGroup.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED);
}
}
providersPanel.setLayout(providersPanelLayout);
providersPanelLayout.setHorizontalGroup(
providersPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(providersPanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(horizontalGroup)
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
providersPanelLayout.setVerticalGroup(
providersPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(verticalGroup)
);
// set initial message (if any)
validateAndStore();
}
void setIssue(BugzillaIssue issue,
List<BugzillaIssue.Attachment> attachments) {
removeAll();
this.issue = issue;
initCollapsedComments();
this.attachments = attachments;
this.attachmentIds = getAttachmentIds(attachments);
BugzillaIssue.Comment[] comments = issue.getComments();
this.sections = new ArrayList<>(comments.length + 1);
GroupLayout layout = new GroupLayout(this);
GroupLayout.ParallelGroup horizontalGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
layout.setHorizontalGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(horizontalGroup)
.addContainerGap());
GroupLayout.SequentialGroup verticalGroup = layout.createSequentialGroup();
verticalGroup.addContainerGap();
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(verticalGroup));
DateFormat format = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT);
String creationTxt = issue.getFieldValue(IssueField.CREATION);
try {
if (!creationTxt.isEmpty()) {
Date creation = dateTimeFormat.parse(creationTxt);
creationTxt = format.format(creation);
}
} catch (ParseException pex) {
Bugzilla.LOG.log(Level.INFO, null, pex);
}
sections.add(addSection(layout,
new Long(0),
issue.getFieldValue(IssueField.DESCRIPTION),
issue.getFieldValue(IssueField.REPORTER),
issue.getFieldValue(IssueField.REPORTER_NAME),
creationTxt, horizontalGroup, verticalGroup, true));
for (BugzillaIssue.Comment comment : comments) {
String when = format.format(comment.getWhen());
sections.add(addSection(layout, comment.getNumber(), comment.getText(), comment.getAuthor(), comment.getAuthorName(), when, horizontalGroup, verticalGroup, false));
}
verticalGroup.addContainerGap();
setLayout(layout);
}
/**
* 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;
}