Java Code Examples for java.awt.GridBagConstraints#BASELINE

The following examples show how to use java.awt.GridBagConstraints#BASELINE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JButtonDemo.java    From pumpernickel with MIT License 6 votes vote down vote up
JPanel createPanel(JComponent... components) {
	JPanel p = new JPanel(new GridBagLayout());
	p.setOpaque(false);
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.weightx = 1;
	c.weighty = 1;
	c.anchor = GridBagConstraints.BASELINE;

	for (JComponent component : components) {
		p.add(component, c);
		c.gridx++;
	}
	return p;
}
 
Example 2
Source File: Inspector.java    From pumpernickel with MIT License 5 votes vote down vote up
/**
 * Append a row containing these elements to this inspector.
 * 
 * @param identifier
 *            the control on the left. This should usually contain text. A
 *            <code>JLabel</code> or a <code>JCheckBox</code> is
 *            recommended.
 * @param controls
 *            a series of controls to group together from left to right. The
 *            cluster of components will be anchored on the left.
 */
public InspectorRowPanel addRow(JComponent identifier,
		JComponent... controls) {
	if (controls.length == 1) {
		return addRow(identifier, controls[0], false);
	}
	prepare(Position.LEAD, identifier);
	JPanel controlPanel = new JPanel(new GridBagLayout());
	controlPanel.setOpaque(false);
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.weightx = 1;
	c.weighty = 1;
	c.anchor = GridBagConstraints.BASELINE;
	for (int a = 0; a < controls.length; a++) {
		Position pos;

		if (a == 0 && a == controls.length - 1) {
			pos = Position.MAIN_WITH_LEAD_NO_STRETCH;
		} else if (a == 0) {
			pos = Position.MAIN_WITH_LEAD_FIRST_IN_SERIES;
		} else if (a == controls.length - 1) {
			pos = Position.MAIN_WITH_LEAD_LAST_IN_SERIES;
		} else {
			pos = Position.MAIN_WITH_LEAD_MIDDLE_IN_SERIES;
		}
		prepare(pos, controls[a]);

		c.insets = getInsets(pos, controls[a]);
		controlPanel.add(controls[a], c);
		c.gridx++;
	}
	controlPanel.putClientProperty(PROPERTY_WRAPPED, Boolean.TRUE);
	return addRow(new InspectorRow(identifier, controlPanel, false, 0));
}
 
Example 3
Source File: PrintPreviewDialog.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void initLayout()
{
	Container pane = getContentPane();
	pane.setLayout(new BorderLayout());
	{//layout top bar
		JPanel bar = new JPanel(new GridBagLayout());
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.fill = GridBagConstraints.HORIZONTAL;
		gbc.anchor = GridBagConstraints.BASELINE;
		gbc.insets = new Insets(8, 6, 8, 2);
		bar.add(new JLabel("Select Template:"), gbc);
		gbc.insets = new Insets(8, 2, 8, 6);
		gbc.weightx = 1;
		bar.add(sheetBox, gbc);
		pane.add(bar, BorderLayout.NORTH);
	}
	{
		Box vbox = Box.createVerticalBox();
		previewPanelParent.setPreferredSize(new Dimension(600, 800));
		vbox.add(previewPanelParent);
		vbox.add(progressBar);
		pane.add(vbox, BorderLayout.CENTER);
	}
	{
		Box hbox = Box.createHorizontalBox();
		hbox.add(new JLabel("Page:"));
		hbox.add(Box.createHorizontalStrut(4));
		hbox.add(pageBox);
		hbox.add(Box.createHorizontalStrut(10));
		hbox.add(new JLabel("Zoom:"));
		hbox.add(Box.createHorizontalStrut(4));
		hbox.add(zoomBox);
		hbox.add(Box.createHorizontalStrut(5));
		hbox.add(zoomInButton);
		hbox.add(Box.createHorizontalStrut(5));
		hbox.add(zoomOutButton);
		hbox.add(Box.createHorizontalGlue());
		hbox.add(printButton);
		hbox.add(Box.createHorizontalStrut(5));
		hbox.add(cancelButton);
		hbox.setBorder(BorderFactory.createEmptyBorder(8, 5, 8, 5));
		pane.add(hbox, BorderLayout.SOUTH);
	}
}
 
Example 4
Source File: CampaignHistoryInfoPane.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void initComponents()
{
	GridBagConstraints gbc = new GridBagConstraints();
	gbc.insets = new Insets(0, 4, 0, 0);
	gbc.gridheight = 1;
	gbc.anchor = GridBagConstraints.BASELINE;
	add(checkBox, gbc);

	gbc.anchor = GridBagConstraints.EAST;
	gbc.insets = new Insets(0, 10, 0, 0);

	GridBagConstraints gbc2 = new GridBagConstraints();
	gbc2.fill = GridBagConstraints.HORIZONTAL;
	gbc2.gridwidth = 3;
	gbc2.insets = new Insets(1, 4, 1, 0);

	add(new JLabel("Campaign:"), gbc);
	add(campaignField, gbc2);
	add(new JLabel("Adventure:"), gbc);
	gbc2.gridwidth = GridBagConstraints.REMAINDER;
	add(adventureField, gbc2);

	add(new JLabel(), gbc);
	add(new JLabel("Party Name:"), gbc);
	gbc2.gridwidth = 1;
	gbc2.weightx = 0.35;
	add(partyField, gbc2);
	add(new JLabel("Date:"), gbc);
	gbc2.weightx = 0.15;
	add(dateField, gbc2);
	add(new JLabel("XP Gained:"), gbc);
	gbc2.weightx = 0.05;
	add(xpField, gbc2);
	add(new JLabel("GM:"), gbc);

	gbc2.gridwidth = GridBagConstraints.REMAINDER;
	gbc2.weightx = 0.45;
	add(gmField, gbc2);

	gbc.fill = GridBagConstraints.VERTICAL;
	gbc.insets = new Insets(0, 0, 2, 0);
	add(deleteButton, gbc);

	gbc.gridwidth = GridBagConstraints.REMAINDER;
	gbc.fill = GridBagConstraints.BOTH;
	gbc.insets = new Insets(0, 10, 0, 0);
	add(textArea, gbc);
}
 
Example 5
Source File: PrintPreviewDialog.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void initLayout()
{
	Container pane = getContentPane();
	pane.setLayout(new BorderLayout());
	{//layout top bar
		JPanel bar = new JPanel(new GridBagLayout());
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.fill = GridBagConstraints.HORIZONTAL;
		gbc.anchor = GridBagConstraints.BASELINE;
		gbc.insets = new Insets(8, 6, 8, 2);
		bar.add(new JLabel("Select Template:"), gbc);
		gbc.insets = new Insets(8, 2, 8, 6);
		gbc.weightx = 1;
		bar.add(sheetBox, gbc);
		pane.add(bar, BorderLayout.NORTH);
	}
	{
		Box vbox = Box.createVerticalBox();
		previewPanelParent.setPreferredSize(new Dimension(600, 800));
		vbox.add(previewPanelParent);
		vbox.add(progressBar);
		pane.add(vbox, BorderLayout.CENTER);
	}
	{
		Box hbox = Box.createHorizontalBox();
		hbox.add(new JLabel("Page:"));
		hbox.add(Box.createHorizontalStrut(4));
		hbox.add(pageBox);
		hbox.add(Box.createHorizontalStrut(10));
		hbox.add(new JLabel("Zoom:"));
		hbox.add(Box.createHorizontalStrut(4));
		hbox.add(zoomBox);
		hbox.add(Box.createHorizontalStrut(5));
		hbox.add(zoomInButton);
		hbox.add(Box.createHorizontalStrut(5));
		hbox.add(zoomOutButton);
		hbox.add(Box.createHorizontalGlue());
		hbox.add(printButton);
		hbox.add(Box.createHorizontalStrut(5));
		hbox.add(cancelButton);
		hbox.setBorder(BorderFactory.createEmptyBorder(8, 5, 8, 5));
		pane.add(hbox, BorderLayout.SOUTH);
	}
}
 
Example 6
Source File: CampaignHistoryInfoPane.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void initComponents()
{
	GridBagConstraints gbc = new GridBagConstraints();
	gbc.insets = new Insets(0, 4, 0, 0);
	gbc.gridheight = 1;
	gbc.anchor = GridBagConstraints.BASELINE;
	add(checkBox, gbc);

	gbc.anchor = GridBagConstraints.EAST;
	gbc.insets = new Insets(0, 10, 0, 0);

	GridBagConstraints gbc2 = new GridBagConstraints();
	gbc2.fill = GridBagConstraints.HORIZONTAL;
	gbc2.gridwidth = 3;
	gbc2.insets = new Insets(1, 4, 1, 0);

	add(new JLabel("Campaign:"), gbc);
	add(campaignField, gbc2);
	add(new JLabel("Adventure:"), gbc);
	gbc2.gridwidth = GridBagConstraints.REMAINDER;
	add(adventureField, gbc2);

	add(new JLabel(), gbc);
	add(new JLabel("Party Name:"), gbc);
	gbc2.gridwidth = 1;
	gbc2.weightx = 0.35;
	add(partyField, gbc2);
	add(new JLabel("Date:"), gbc);
	gbc2.weightx = 0.15;
	add(dateField, gbc2);
	add(new JLabel("XP Gained:"), gbc);
	gbc2.weightx = 0.05;
	add(xpField, gbc2);
	add(new JLabel("GM:"), gbc);

	gbc2.gridwidth = GridBagConstraints.REMAINDER;
	gbc2.weightx = 0.45;
	add(gmField, gbc2);

	gbc.fill = GridBagConstraints.VERTICAL;
	gbc.insets = new Insets(0, 0, 2, 0);
	add(deleteButton, gbc);

	gbc.gridwidth = GridBagConstraints.REMAINDER;
	gbc.fill = GridBagConstraints.BOTH;
	gbc.insets = new Insets(0, 10, 0, 0);
	add(textArea, gbc);
}