当前位置: 首页>>代码示例>>Java>>正文


Java GroupLayout.setAutoCreateContainerGaps方法代码示例

本文整理汇总了Java中javax.swing.GroupLayout.setAutoCreateContainerGaps方法的典型用法代码示例。如果您正苦于以下问题:Java GroupLayout.setAutoCreateContainerGaps方法的具体用法?Java GroupLayout.setAutoCreateContainerGaps怎么用?Java GroupLayout.setAutoCreateContainerGaps使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.GroupLayout的用法示例。


在下文中一共展示了GroupLayout.setAutoCreateContainerGaps方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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)
	);
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:35,代码来源:MultiAlgoScenarioWizard.java

示例2: 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));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ChooseBeanInitializer.java

示例3: resetLayout

import javax.swing.GroupLayout; //导入方法依赖的package包/类
private void resetLayout() {
    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    layout.setAutoCreateContainerGaps(true);
    layout.setHorizontalGroup(layout.createSequentialGroup()
        .addComponent(headerLabel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
        .addGap(3)
        .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane, GroupLayout.PREFERRED_SIZE, 320, Short.MAX_VALUE)
            .addComponent(typeField))
        .addGap(3)
        .addComponent(footerLabel));        
    
           
    int prefHeight;
    int maxHeight;
    if(jScrollPane.getPreferredSize().getHeight() > 300) {
        prefHeight = 300;
        maxHeight = GroupLayout.DEFAULT_SIZE;
    } else {
        prefHeight = GroupLayout.DEFAULT_SIZE;
        maxHeight = GroupLayout.PREFERRED_SIZE;
    }
    
    layout.setVerticalGroup(layout.createSequentialGroup()
        .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(jScrollPane.getInsets().top)
                .addGroup(layout.createParallelGroup().addComponent(headerLabel).addComponent(footerLabel)))
            .addComponent(jScrollPane, GroupLayout.DEFAULT_SIZE, prefHeight, maxHeight))
        .addComponent(typeField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:CodeCustomEditor.java

示例4: 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);
}
 
开发者ID:pascalgn,项目名称:jiracli,代码行数:37,代码来源:ConsoleTextAreaDemo.java

示例5: 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;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:61,代码来源:ConstraintsGeneratorDialog.java

示例6: 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;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:54,代码来源:ConstraintsGeneratorDialog.java

示例7: 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;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:48,代码来源:HiddenHopsDialog.java

示例8: 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);
}
 
开发者ID:KevinPriv,项目名称:Luyten4Forge,代码行数:78,代码来源:FindBox.java


注:本文中的javax.swing.GroupLayout.setAutoCreateContainerGaps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。