本文整理汇总了Java中javax.swing.GroupLayout.linkSize方法的典型用法代码示例。如果您正苦于以下问题:Java GroupLayout.linkSize方法的具体用法?Java GroupLayout.linkSize怎么用?Java GroupLayout.linkSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.GroupLayout
的用法示例。
在下文中一共展示了GroupLayout.linkSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: layoutSelectResourcePanel
import javax.swing.GroupLayout; //导入方法依赖的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));
}
示例2: FindBox
import javax.swing.GroupLayout; //导入方法依赖的package包/类
public FindBox(final MainWindow mainWindow) {
this.mainWindow = mainWindow;
this.setDefaultCloseOperation(HIDE_ON_CLOSE);
this.setHideOnEscapeButton();
JLabel label = new JLabel("Find What:");
textField = new JTextField();
RSyntaxTextArea pane = mainWindow.getModel().getCurrentTextArea();
if (pane != null) {
textField.setText(pane.getSelectedText());
}
mcase = new JCheckBox("Match Case");
regex = new JCheckBox("Regex");
wholew = new JCheckBox("Whole Words");
reverse = new JCheckBox("Search Backwards");
wrap = new JCheckBox("Wrap");
findButton = new JButton("Find");
findButton.addActionListener(new FindButton());
this.getRootPane().setDefaultButton(findButton);
KeyStroke funcF3 = KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0, false);
this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(funcF3, "FindNext");
this.getRootPane().getActionMap().put("FindNext", new FindExploreAction(true));
KeyStroke sfuncF3 = KeyStroke.getKeyStroke(KeyEvent.VK_F3, InputEvent.SHIFT_DOWN_MASK, false);
this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(sfuncF3, "FindPrevious");
this.getRootPane().getActionMap().put("FindPrevious", new FindExploreAction(false));
mcase.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
regex.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
wholew.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
reverse.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
wrap.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
final Dimension center = new Dimension((int) (screenSize.width * 0.35),
Math.min((int) (screenSize.height * 0.20), 200));
final int x = (int) (center.width * 0.2);
final int y = (int) (center.height * 0.2);
this.setBounds(x, y, center.width, center.height);
this.setResizable(false);
GroupLayout layout = new GroupLayout(getRootPane());
getRootPane().setLayout(layout);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
layout.setHorizontalGroup(layout.createSequentialGroup().addComponent(label)
.addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(textField)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(mcase)
.addComponent(wholew).addComponent(wrap))
.addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(regex)
.addComponent(reverse))))
.addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(findButton)));
layout.linkSize(SwingConstants.HORIZONTAL, findButton);
layout.setVerticalGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(label).addComponent(textField)
.addComponent(findButton))
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(mcase)
.addComponent(regex))
.addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(wholew)
.addComponent(reverse))
.addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(wrap)))));
this.adjustWindowPositionBySavedState();
this.setSaveWindowPositionOnClosing();
this.setName("Find");
this.setTitle("Find");
this.setVisible(true);
}