下面列出了javax.swing.GroupLayout#SequentialGroup ( ) 实例代码,或者点击链接到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 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);
}
}
protected void createLayout() {
this.removeAll();
GroupLayout.ParallelGroup horizontalGroup = layout.createParallelGroup();
GroupLayout.SequentialGroup verticalGroup = layout.createSequentialGroup();
for (JComponent jComponent : components) {
horizontalGroup.addComponent(jComponent);
if (jComponent instanceof JLabel
|| jComponent instanceof JButton
|| jComponent instanceof JCheckBox
|| jComponent instanceof JTextField
|| jComponent instanceof JComboBox) {
verticalGroup.addComponent(jComponent, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight());
} else {
verticalGroup.addComponent(jComponent);
}
}
layout.setHorizontalGroup(
layout.createSequentialGroup()
.addGroup(horizontalGroup)
);
layout.setVerticalGroup(
layout.createSequentialGroup()
.addGroup(verticalGroup)
);
}
private void layoutHeaderPanel(JPanel headerPanel, JLabel iconLabel, JLabel leftLabel, JLabel commentLabel, JLabel rightLabel, LinkButton replyButton, LinkButton mailtoButton, JLabel stateLabel) {
GroupLayout layout = new GroupLayout(headerPanel);
headerPanel.setLayout(layout);
GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup()
.addComponent(iconLabel)
.addComponent(leftLabel);
if (stateLabel != null) {
hGroup.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(stateLabel);
}
hGroup.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(commentLabel,0, 0, Short.MAX_VALUE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(rightLabel)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(replyButton);
if (mailtoButton != null) {
hGroup.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(mailtoButton);
}
layout.setHorizontalGroup(hGroup);
GroupLayout.ParallelGroup vGroup = layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(iconLabel)
.addComponent(leftLabel);
if (stateLabel != null) {
vGroup.addComponent(stateLabel);
}
vGroup.addComponent(commentLabel)
.addComponent(rightLabel)
.addComponent(replyButton);
if (mailtoButton != null) {
vGroup.addComponent(mailtoButton);
}
layout.setVerticalGroup(vGroup);
}
/**
* 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;
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the FormEditor.
*/
// <editor-fold defaultstate="collapsed" desc="UI Initialization Code">
private void initComponents() {
contentsPanelPlaceholder = new JPanel(cardLayout);
if (withButtons) {
replaceButton = new JButton();
skipButton = new JButton();
ignoreButton = new JButton();
infoButton = new JButton();
cancelButton = new JButton();
helpButton = new JButton();
Mnemonics.setLocalizedText(replaceButton, bundle.getString("CTL_ReplaceButton")); // NOI18N
Mnemonics.setLocalizedText(skipButton, bundle.getString("CTL_SkipButton")); // NOI18N
Mnemonics.setLocalizedText(ignoreButton, bundle.getString("CTL_IgnoreButton")); // NOI18N
Mnemonics.setLocalizedText(infoButton, bundle.getString("CTL_InfoButton")); // NOI18N
Mnemonics.setLocalizedText(cancelButton, bundle.getString("CTL_CloseButton")); // NOI18N
Mnemonics.setLocalizedText(helpButton, bundle.getString("CTL_HelpButton")); // NOI18N
helpButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
helpButtonActionPerformed(evt);
}
});
}
GroupLayout layout;
setLayout (layout = new GroupLayout(this));
GroupLayout.SequentialGroup horizGroup = layout.createSequentialGroup();
horizGroup.addContainerGap();
if (withButtons) {
horizGroup.addGroup(
layout.createParallelGroup(TRAILING)
.addComponent(contentsPanelPlaceholder)
.addGroup(layout.createSequentialGroup()
.addComponent(replaceButton)
.addPreferredGap(RELATED)
.addComponent(skipButton)
.addPreferredGap(RELATED)
.addComponent(ignoreButton)
.addPreferredGap(RELATED)
.addComponent(infoButton)
.addPreferredGap(RELATED)
.addComponent(cancelButton)
.addPreferredGap(RELATED)
.addComponent(helpButton)));
layout.linkSize(SwingConstants.HORIZONTAL, cancelButton,
helpButton,
infoButton,
replaceButton,
ignoreButton,
skipButton);
} else {
horizGroup.addComponent(contentsPanelPlaceholder);
}
horizGroup.addContainerGap();
layout.setHorizontalGroup(horizGroup);
GroupLayout.SequentialGroup vertGroup = layout.createSequentialGroup();
vertGroup.addContainerGap();
vertGroup.addComponent(contentsPanelPlaceholder);
if (withButtons) {
vertGroup
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(BASELINE)
.addComponent(helpButton)
.addComponent(cancelButton)
.addComponent(infoButton)
.addComponent(skipButton)
.addComponent(ignoreButton)
.addComponent(replaceButton));
}
vertGroup.addContainerGap();
layout.setVerticalGroup(vertGroup);
}
@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 setLayoutGroups(GroupLayout.ParallelGroup horizontalGroup,
GroupLayout.SequentialGroup verticalGroup) {
this.horizontalGroup = horizontalGroup;
this.verticalGroup = verticalGroup;
}
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);
}
private void update(boolean sort) {
//Save focus owner
Component focusOwner = jFrame.getFocusOwner();
//Update group
updateGroupSize();
jPanel.removeAll();
GroupLayout.ParallelGroup horizontalGroup = layout.createParallelGroup();
GroupLayout.SequentialGroup verticalGroup = layout.createSequentialGroup();
//Toolbars
horizontalGroup.addGroup(
layout.createSequentialGroup()
.addComponent(jToolBarLeft, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, Integer.MAX_VALUE)
.addGap(0)
.addComponent(jToolBarRight, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
);
verticalGroup.addGroup(
layout.createParallelGroup()
.addComponent(jToolBarLeft, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(jToolBarRight, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
);
//Filters
if (jShowFilters.isSelected()) {
if (sort) {
Collections.sort(filterPanels);
}
int group = -1;
for (FilterPanel<E> filterPanel : filterPanels) {
if (!filterPanel.isMoving()) {
if (group > -1 && group != filterPanel.getGroup()) {
FilterPanelSeparator separator = new FilterPanelSeparator(group);
horizontalGroup.addComponent(separator.getPanel());
verticalGroup.addGap(0).addComponent(separator.getPanel(), GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE).addGap(0);
}
group = filterPanel.getGroup();
}
horizontalGroup.addComponent(filterPanel.getPanel());
verticalGroup.addComponent(filterPanel.getPanel(), GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE);
}
}
layout.setHorizontalGroup(horizontalGroup);
layout.setVerticalGroup(verticalGroup);
//Load focus owner
if (focusOwner != null) {
focusOwner.requestFocusInWindow();
}
}
public boolean show(List<DeprecatedOwner> owners) {
returnValue = false;
jPanel.removeAll();
containers.clear();
for (DeprecatedOwner owner : owners) {
List<EsiOwner> esiOwners = new ArrayList<EsiOwner>();
for (EsiOwner esiOwner : program.getProfileManager().getEsiOwners()) {
if (esiOwner.getOwnerID() == owner.getOwnerID()) {
esiOwners.add(esiOwner);
}
}
containers.add(new OwnerContainer(owner, esiOwners));
}
validateAll();
GroupLayout.ParallelGroup horizontalGroup = layout.createParallelGroup(GroupLayout.Alignment.TRAILING);
GroupLayout.SequentialGroup verticalGroup = layout.createSequentialGroup();
GroupLayout.SequentialGroup horizontalContainer = layout.createSequentialGroup();
horizontalGroup.addGroup(horizontalContainer);
GroupLayout.ParallelGroup horizontalCheckBox = layout.createParallelGroup();
horizontalContainer.addGroup(horizontalCheckBox);
GroupLayout.ParallelGroup horizontalComboBox = layout.createParallelGroup();
GroupLayout.ParallelGroup horizontalButton = layout.createParallelGroup();
GroupLayout.ParallelGroup horizontalLabel = layout.createParallelGroup();
horizontalContainer.addGroup(layout.createParallelGroup()
.addComponent(jHelp)
.addGroup(layout.createSequentialGroup()
.addGroup(horizontalComboBox)
.addGroup(horizontalButton)
.addGroup(horizontalLabel)
)
);
horizontalCheckBox.addComponent(jAll);
verticalGroup.addGroup(layout.createParallelGroup()
.addComponent(jAll)
.addComponent(jHelp)
);
for (OwnerContainer container : containers) {
horizontalCheckBox.addComponent(container.getCheckBox());
horizontalComboBox.addComponent(container.getComboBox());
horizontalButton.addComponent(container.getButton());
horizontalLabel.addComponent(container.getLabel());
verticalGroup.addGroup(layout.createParallelGroup()
.addComponent(container.getCheckBox(), Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(container.getComboBox(), Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(container.getButton(), Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(container.getLabel(), Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
);
}
horizontalGroup.addGroup(layout.createSequentialGroup()
.addComponent(jOK, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
.addComponent(jCancel, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
);
verticalGroup.addGroup(layout.createParallelGroup()
.addComponent(jOK, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
.addComponent(jCancel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
);
layout.setHorizontalGroup(horizontalGroup);
layout.setVerticalGroup(verticalGroup);
setVisible(true);
return returnValue;
}