本文整理匯總了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;
}