本文整理汇总了Java中javax.swing.LayoutStyle.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java LayoutStyle.getInstance方法的具体用法?Java LayoutStyle.getInstance怎么用?Java LayoutStyle.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.LayoutStyle
的用法示例。
在下文中一共展示了LayoutStyle.getInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeVerticalStrut
import javax.swing.LayoutStyle; //导入方法依赖的package包/类
private static Component makeVerticalStrut(JComponent compA,
JComponent compB) {
LayoutStyle layoutStyle = LayoutStyle.getInstance();
return Box.createVerticalStrut(
layoutStyle.getPreferredGap(compA,
compB,
UNRELATED,
SOUTH,
compA.getParent()));
}
示例2: addContainerBorder
import javax.swing.LayoutStyle; //导入方法依赖的package包/类
public static JComponent addContainerBorder(JComponent comp) {
final LayoutStyle layoutStyle = LayoutStyle.getInstance();
JPanel panel = new JPanel();
panel.add(comp);
panel.setBorder(BorderFactory.createEmptyBorder(
layoutStyle.getContainerGap(comp, SwingConstants.NORTH, null),
layoutStyle.getContainerGap(comp, SwingConstants.WEST, null),
layoutStyle.getContainerGap(comp, SwingConstants.SOUTH, null),
layoutStyle.getContainerGap(comp, SwingConstants.EAST, null)));
return panel;
}
示例3: addInsetsToPanel
import javax.swing.LayoutStyle; //导入方法依赖的package包/类
private static void addInsetsToPanel(JComponent comp) {
LayoutStyle layoutStyle = LayoutStyle.getInstance();
comp.setBorder(BorderFactory.createEmptyBorder(
layoutStyle.getContainerGap(comp, NORTH, null),
layoutStyle.getContainerGap(comp, WEST, null),
layoutStyle.getContainerGap(comp, SOUTH, null),
layoutStyle.getContainerGap(comp, EAST, null)));
}
示例4: layoutSelectResourcePanel
import javax.swing.LayoutStyle; //导入方法依赖的package包/类
/**
* @author Marian Petras
*/
static void layoutSelectResourcePanel(final Container thePanel,
final String instructionsText,
final String selectionLabelText,
final Component selectionComp,
final JButton button1,
final JButton button2) {
JTextArea instructions = new JTextArea();
JLabel lblSelection = new JLabel();
instructions.setColumns(20);
instructions.setEditable(false);
instructions.setLineWrap(true);
instructions.setText(instructionsText);
instructions.setWrapStyleWord(true);
instructions.setDisabledTextColor(new JLabel().getForeground());
instructions.setEnabled(false);
instructions.setOpaque(false);
lblSelection.setLabelFor(selectionComp);
Mnemonics.setLocalizedText(lblSelection, selectionLabelText);
JScrollPane scrollPane = new JScrollPane(selectionComp);
Container filesSelection = new JPanel();
GroupLayout layout = new GroupLayout(filesSelection);
filesSelection.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(LEADING)
.addComponent(lblSelection)
.addGroup(layout.createSequentialGroup()
.addComponent(scrollPane, 0, DEFAULT_SIZE, Integer.MAX_VALUE)
.addPreferredGap(RELATED)
.addGroup(layout.createParallelGroup(LEADING)
.addComponent(button1)
.addComponent(button2)))
);
layout.linkSize(SwingConstants.HORIZONTAL, button1, button2);
layout.setVerticalGroup(
layout.createParallelGroup(LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblSelection)
.addPreferredGap(RELATED)
.addGroup(layout.createParallelGroup(LEADING)
.addComponent(scrollPane, 0, DEFAULT_SIZE, Integer.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(button1)
.addPreferredGap(RELATED)
.addComponent(button2))))
);
LayoutStyle layoutStyle = layout.getLayoutStyle();
if (layoutStyle == null) {
layoutStyle = LayoutStyle.getInstance();
}
BorderLayout mainLayout = new BorderLayout();
thePanel.setLayout(mainLayout);
thePanel.add(instructions, BorderLayout.PAGE_START);
thePanel.add(filesSelection, BorderLayout.CENTER);
mainLayout.setVgap(layoutStyle.getPreferredGap(instructions,
lblSelection,
UNRELATED,
SwingConstants.NORTH,
thePanel));
}
示例5: getLeftContainerGap
import javax.swing.LayoutStyle; //导入方法依赖的package包/类
private static int getLeftContainerGap(JComponent comp) {
LayoutStyle layoutStyle = LayoutStyle.getInstance();
return layoutStyle.getContainerGap(comp, WEST, null);
}
示例6: selectIssue
import javax.swing.LayoutStyle; //导入方法依赖的package包/类
public static Issue selectIssue(String message, Repository repository, JPanel caller, HelpCtx helpCtx) {
QuickSearchComboBar bar = new QuickSearchComboBar(caller);
bar.setRepository(repository);
bar.setAlignmentX(0f);
bar.setMaximumSize(new Dimension(Short.MAX_VALUE, bar.getPreferredSize().height));
JPanel panel = new JPanel();
BoxLayout layout = new BoxLayout(panel, BoxLayout.PAGE_AXIS);
panel.setLayout(layout);
JLabel label = new JLabel();
Mnemonics.setLocalizedText(label, message);
panel.add(label);
label.setLabelFor(bar.getIssueComponent());
LayoutStyle layoutStyle = LayoutStyle.getInstance();
int gap = layoutStyle.getPreferredGap(label, bar, LayoutStyle.ComponentPlacement.RELATED, SwingConstants.SOUTH, panel);
panel.add(Box.createVerticalStrut(gap));
panel.add(bar);
panel.add(Box.createVerticalStrut(gap));
ResourceBundle bundle = NbBundle.getBundle(QuickSearchComboBar.class);
JLabel hintLabel = new JLabel(bundle.getString("MSG_SelectIssueHint")); // NOI18N
hintLabel.setEnabled(false);
panel.add(hintLabel);
panel.add(Box.createVerticalStrut(80));
panel.setBorder(BorderFactory.createEmptyBorder(
layoutStyle.getContainerGap(panel, SwingConstants.NORTH, null),
layoutStyle.getContainerGap(panel, SwingConstants.WEST, null),
0,
layoutStyle.getContainerGap(panel, SwingConstants.EAST, null)));
panel.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_IssueSelector"));
Issue issue = null;
JButton ok = new JButton(bundle.getString("LBL_Select")); // NOI18N
ok.getAccessibleContext().setAccessibleDescription(ok.getText());
JButton cancel = new JButton(bundle.getString("LBL_Cancel")); // NOI18N
cancel.getAccessibleContext().setAccessibleDescription(cancel.getText());
DialogDescriptor descriptor = new DialogDescriptor(
panel,
bundle.getString("LBL_Issues"), // NOI18N
true,
NotifyDescriptor.OK_CANCEL_OPTION,
ok,
null);
descriptor.setOptions(new Object [] {ok, cancel});
descriptor.setHelpCtx(helpCtx);
DialogDisplayer.getDefault().createDialog(descriptor).setVisible(true);
if (descriptor.getValue() == ok) {
issue = bar.getIssue();
}
return issue;
}