本文整理汇总了Java中javax.swing.GroupLayout.setAutoCreateGaps方法的典型用法代码示例。如果您正苦于以下问题:Java GroupLayout.setAutoCreateGaps方法的具体用法?Java GroupLayout.setAutoCreateGaps怎么用?Java GroupLayout.setAutoCreateGaps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.GroupLayout
的用法示例。
在下文中一共展示了GroupLayout.setAutoCreateGaps方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCustomEditorGUI
import javax.swing.GroupLayout; //导入方法依赖的package包/类
protected Component createCustomEditorGUI(Component resourcePanelGUI) {
if (resourcePanelGUI == null)
return delegateEditor.getCustomEditor();
JPanel panel = new JPanel();
Component delComp = delegateEditor.getCustomEditor();
GroupLayout layout = new GroupLayout(panel);
panel.setLayout(layout);
layout.setAutoCreateGaps(true);
layout.setHorizontalGroup(layout.createParallelGroup()
.addComponent(delComp)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(resourcePanelGUI)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)));
layout.setVerticalGroup(layout.createSequentialGroup()
.addComponent(delComp).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(resourcePanelGUI));
return panel;
}
示例2: initGUI
import javax.swing.GroupLayout; //导入方法依赖的package包/类
private void initGUI() {
// Fill dropdown.
String[] items = this.classnames.keySet().toArray(new String[0]);
this.dropdown = new JComboBox<String>(items);
// Select current generator in dropdown.
for(int i = 0; i < items.length; i++) {
if (this.generator.getName().equals(items[i])) {
this.dropdown.setSelectedIndex(i);
}
}
// Create label.
JLabel dropdownLabel = new JLabel("Generator:");
dropdownLabel.setLabelFor(this.dropdown);
dropdownLabel.setHorizontalAlignment(JLabel.TRAILING);
// Initialize layout and add components to GUI.
GroupLayout layout = new GroupLayout(this.panel);
this.panel.setLayout(layout);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
layout.setHorizontalGroup(layout
.createSequentialGroup()
.addComponent(dropdownLabel)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(this.dropdown)
);
layout.setVerticalGroup(layout
.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(dropdownLabel)
.addComponent(this.dropdown)
);
}
示例3: ChooseBeanPanel
import javax.swing.GroupLayout; //导入方法依赖的package包/类
ChooseBeanPanel() {
JLabel nameLabel = new JLabel(NbBundle.getMessage(ChooseBeanInitializer.class, "MSG_Choose_Bean")); // NOI18N
nameField = new JTextField(25);
GroupLayout layout = new GroupLayout(this);
layout.setAutoCreateContainerGaps(true);
layout.setAutoCreateGaps(true);
setLayout(layout);
layout.setHorizontalGroup(layout.createSequentialGroup()
.addComponent(nameLabel).addComponent(nameField));
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(nameLabel).addComponent(nameField));
}
示例4: layoutComponents
import javax.swing.GroupLayout; //导入方法依赖的package包/类
private void layoutComponents() {
JLabel titleLabel = new JLabel("Please enter the credentials for " + url);
int em = getFontMetrics(getFont()).stringWidth("m");
GroupLayout groupLayout = new GroupLayout(this);
groupLayout.setAutoCreateGaps(true);
groupLayout.setHorizontalGroup(groupLayout.createParallelGroup()
.addComponent(titleLabel)
.addComponent(usernamePassword)
.addGroup(groupLayout.createSequentialGroup().addGap(3 * em)
.addGroup(groupLayout.createParallelGroup().addComponent(usernameLabel)
.addComponent(passwordLabel))
.addGroup(groupLayout.createParallelGroup()
.addComponent(username, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE)
.addComponent(password, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE)))
.addComponent(anonymous));
groupLayout.setVerticalGroup(groupLayout.createSequentialGroup()
.addComponent(titleLabel).addComponent(usernamePassword)
.addGroup(
groupLayout.createBaselineGroup(true, false).addComponent(usernameLabel).addComponent(username))
.addGroup(
groupLayout.createBaselineGroup(true, false).addComponent(passwordLabel).addComponent(password))
.addComponent(anonymous));
setLayout(groupLayout);
}
示例5: layoutComponents
import javax.swing.GroupLayout; //导入方法依赖的package包/类
private void layoutComponents() {
JScrollPane printTextScrollPane = new JScrollPane(appendTextInput);
printTextScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
JSeparator separator1 = new JSeparator();
JScrollPane readLineTextScrollPane = new JScrollPane(readLineOutput);
readLineTextScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
JSeparator separator2 = new JSeparator();
JScrollPane consoleScrollPane = new JScrollPane(consoleText);
consoleScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
GroupLayout groupLayout = new GroupLayout(this);
groupLayout.setAutoCreateContainerGaps(true);
groupLayout.setAutoCreateGaps(true);
groupLayout.setHorizontalGroup(groupLayout.createParallelGroup().addComponent(printTextScrollPane)
.addComponent(appendText, Alignment.TRAILING).addComponent(separator1)
.addComponent(readLine, Alignment.TRAILING).addComponent(readLineTextScrollPane)
.addComponent(separator2).addComponent(consoleScrollPane));
groupLayout.setVerticalGroup(groupLayout.createSequentialGroup()
.addComponent(printTextScrollPane, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE)
.addComponent(appendText)
.addComponent(separator1, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE)
.addComponent(readLine)
.addComponent(readLineTextScrollPane, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE)
.addComponent(separator2, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
GroupLayout.PREFERRED_SIZE)
.addComponent(consoleScrollPane));
setLayout(groupLayout);
}
示例6: getTableCellRendererComponent
import javax.swing.GroupLayout; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row,
int column) {
JPanel panel = new JPanel();
if (value instanceof String[]) {
String[] valueArray = (String[]) value;
if (valueArray.length == 0)
return panel;
GroupLayout layout = new GroupLayout(panel);
panel.setLayout(layout);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
SequentialGroup cols = layout.createSequentialGroup();
layout.setHorizontalGroup(cols);
ParallelGroup col1 = layout
.createParallelGroup(GroupLayout.Alignment.LEADING);
ParallelGroup col2 = layout
.createParallelGroup(GroupLayout.Alignment.TRAILING);
cols.addGroup(col1)
.addPreferredGap(
LayoutStyle.ComponentPlacement.RELATED,
GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(col2);
SequentialGroup rows = layout.createSequentialGroup();
layout.setVerticalGroup(rows);
for (int i = 0; i < valueArray.length; i++) {
// the value array has null elements for
// IdResource/Demand
if (valueArray[i] != null) {
/* TODO: Fix ArrayIndexOutofBounds Exception here
* Update: Problem is actually above. Probably linked to resources without setters. */
//System.out.println("ValueArray: " + valueArray[i]);
//for (int j = 0; j < resParamNames.size(); j++) { System.out.println("resParamNames: " + resParamNames.get(j)); }
JLabel label = new JLabel();
if (resParamNames.get(row).length == 0)
label.setText("max. param");
else
label.setText("max. " + resParamNames.get(row)[i]);
JTextField tf = new JTextField(3);
tf.setText(valueArray[i]);
col1.addComponent(label);
col2.addComponent(tf, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE);
rows.addGroup(layout
.createParallelGroup(
GroupLayout.Alignment.CENTER)
.addComponent(label).addComponent(tf));
}
}
}
table.setRowHeight(row, Math.max(table.getRowHeight(row),
(int) panel.getPreferredSize().getHeight()));
TableColumn cm = table.getColumnModel().getColumn(column);
cm.setMinWidth(Math.max(cm.getMinWidth(), (int) panel
.getPreferredSize().getWidth()));
return panel;
}
示例7: getTableCellEditorComponent
import javax.swing.GroupLayout; //导入方法依赖的package包/类
@Override
public Component getTableCellEditorComponent(JTable table,
Object value, boolean isSelected, int row, int column) {
panel = new JPanel();
if (value instanceof String[]) {
String[] valueArray = (String[]) value;
if (valueArray.length == 0)
return panel;
GroupLayout layout = new GroupLayout(panel);
panel.setLayout(layout);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
SequentialGroup cols = layout.createSequentialGroup();
layout.setHorizontalGroup(cols);
ParallelGroup col1 = layout
.createParallelGroup(GroupLayout.Alignment.LEADING);
ParallelGroup col2 = layout
.createParallelGroup(GroupLayout.Alignment.TRAILING);
cols.addGroup(col1)
.addPreferredGap(
LayoutStyle.ComponentPlacement.RELATED,
GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(col2);
SequentialGroup rows = layout.createSequentialGroup();
layout.setVerticalGroup(rows);
for (int i = 0; i < valueArray.length; i++) {
// create the label. use the resource param name for both
// resource and demand params as it should be the same. TODO
JLabel label = new JLabel();
if (resParamNames.get(row).length == 0)
label.setText("max. param");
else
label.setText("max. " + resParamNames.get(row)[i]);
JTextField tf = new JTextField(3);
tf.setText(valueArray[i]);
tf.setEditable(true);
col1.addComponent(label);
col2.addComponent(tf, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE);
rows.addGroup(layout
.createParallelGroup(GroupLayout.Alignment.CENTER)
.addComponent(label).addComponent(tf));
}
}
table.setRowHeight(row, Math.max(table.getRowHeight(row),
(int) panel.getPreferredSize().getHeight()));
TableColumn cm = table.getColumnModel().getColumn(column);
cm.setMinWidth(Math.max(cm.getMinWidth(), (int) panel
.getPreferredSize().getWidth()));
return panel;
}
示例8: createContent
import javax.swing.GroupLayout; //导入方法依赖的package包/类
@Override
protected JPanel createContent() {
JPanel content = new JPanel();
GroupLayout layout = new GroupLayout(content);
content.setLayout(layout);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
// parameters panel
hhTable = new JTable();
hhTable.setAutoscrolls(true);
JScrollPane resScrollPane = new JScrollPane(hhTable);
resScrollPane
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
resScrollPane
.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
hhTable.setFillsViewportHeight(true);
hhTable.setPreferredScrollableViewportSize(new Dimension(400, 100));
hhTableModel = new MyTableModel();
hhTable.setModel(hhTableModel);
hhTable.setDefaultRenderer(Class.class, new MyClassTableCellRenderer());
hhTable.setDefaultEditor(Double.class, new MyDoubleTableCellEditor());
hhTableModel.addColumn("Select");
hhTableModel.addColumn("Hidden Hop Mapping");
hhTableModel.addColumn("Factor");
JPanel hhPanel = new JPanel();
hhPanel.setBorder(BorderFactory.createTitledBorder("Hidden Hops"));
hhPanel.add(resScrollPane);
// create the content for the hh panel
for (Class<?> hh : getAllHhs()) {
try {
hh.getDeclaredField(new String("factor"));
// add a row to the factor table.
hhTableModel
.addRow(new Object[] { false, hh, new Double(0.0) });
} catch (NoSuchFieldException ex) {
}
}
// add the panels
layout.setHorizontalGroup(layout.createParallelGroup().addComponent(
hhPanel));
layout.setVerticalGroup(layout.createSequentialGroup().addComponent(
hhPanel));
return content;
}
示例9: getCustomEditor
import javax.swing.GroupLayout; //导入方法依赖的package包/类
@Override
public Component getCustomEditor () {
if (customEditor == null) {
JTextArea textArea = new JTextArea();
textArea.setWrapStyleWord(true);
textArea.setLineWrap(true);
textArea.setColumns(60);
textArea.setRows(8);
textArea.getDocument().addDocumentListener(this);
textArea.getAccessibleContext().setAccessibleName(
NbBundle.getBundle(StringEditor.class).getString("ACSN_StringEditorTextArea")); //NOI18N
textArea.getAccessibleContext().setAccessibleDescription(
NbBundle.getBundle(StringEditor.class).getString("ACSD_StringEditorTextArea")); //NOI18N
JScrollPane scroll = new JScrollPane();
scroll.setViewportView(textArea);
JLabel htmlTipLabel = new JLabel(NbBundle.getMessage(StringEditor.class, "StringEditor.htmlTipLabel.text")); // NOI18N
JPanel panel = new JPanel();
GroupLayout layout = new GroupLayout(panel);
layout.setAutoCreateGaps(true);
panel.setLayout(layout);
layout.setHorizontalGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup()
.addComponent(scroll)
.addComponent(htmlTipLabel))
.addContainerGap());
layout.setVerticalGroup(layout.createSequentialGroup()
.addContainerGap().addComponent(scroll).addComponent(htmlTipLabel));
customEditor = panel;
textComp = textArea;
htmlTipLabel.setVisible(htmlText);
}
textComp.setEditable(editable);
setValueToCustomEditor();
return customEditor;
}
示例10: 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);
}