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