Java Code Examples for javax.swing.JComponent#getUIClassID()

The following examples show how to use javax.swing.JComponent#getUIClassID() . These examples are extracted from open source projects. 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 Project: RipplePower   File: WindowsLayoutStyle.java    License: Apache License 2.0 6 votes vote down vote up
public int getPreferredGap(JComponent source, JComponent target, int type, int position, Container parent) {
	super.getPreferredGap(source, target, type, position, parent);

	if (type == INDENT) {
		if (position == SwingConstants.EAST || position == SwingConstants.WEST) {
			int gap = getButtonChildIndent(source, position);
			if (gap != 0) {
				return gap;
			}
			return 10;
		}
		type = RELATED;
	}
	if (type == UNRELATED) {
		return getCBRBPadding(source, target, position, dluToPixels(7, position));
	} else {
		boolean sourceLabel = (source.getUIClassID() == "LabelUI");
		boolean targetLabel = (target.getUIClassID() == "LabelUI");

		if (((sourceLabel && !targetLabel) || (targetLabel && !sourceLabel))
				&& (position == SwingConstants.EAST || position == SwingConstants.WEST)) {
			return getCBRBPadding(source, target, position, dluToPixels(3, position));
		}
		return getCBRBPadding(source, target, position, dluToPixels(4, position));
	}
}
 
Example 2
Source Project: RipplePower   File: MetalLayoutStyle.java    License: Apache License 2.0 5 votes vote down vote up
private int getButtonAdjustment(JComponent source, int edge) {
	String uid = source.getUIClassID();
	if (uid == "ButtonUI" || uid == "ToggleButtonUI") {
		if (!isOcean && (edge == SwingConstants.EAST || edge == SwingConstants.SOUTH)) {
			return 1;
		}
	} else if (edge == SwingConstants.SOUTH) {
		if (uid == "RadioButtonUI" || (!isOcean && uid == "CheckBoxUI")) {
			return 1;
		}
	}
	return 0;
}
 
Example 3
Source Project: RipplePower   File: LayoutStyle.java    License: Apache License 2.0 5 votes vote down vote up
private int getCBRBPadding(JComponent c, int position) {
	if (c.getUIClassID() == "CheckBoxUI" || c.getUIClassID() == "RadioButtonUI") {
		Border border = c.getBorder();
		if (border instanceof UIResource) {
			return getInset(c, position);
		}
	}
	return 0;
}
 
Example 4
Source Project: RipplePower   File: MetalLayoutStyle.java    License: Apache License 2.0 4 votes vote down vote up
public int getPreferredGap(JComponent source, JComponent target, int type, int position, Container parent) {
	// Invoke super to check arguments.
	super.getPreferredGap(source, target, type, position, parent);

	if (type == INDENT) {
		if (position == SwingConstants.EAST || position == SwingConstants.WEST) {
			int gap = getButtonChildIndent(source, position);
			if (gap != 0) {
				return gap;
			}
			return 12;
		}
		// Treat vertical INDENT as RELATED
		type = RELATED;
	}

	String sourceCID = source.getUIClassID();
	String targetCID = target.getUIClassID();
	int offset;

	if (type == RELATED) {
		if (sourceCID == "ToggleButtonUI" && targetCID == "ToggleButtonUI") {
			ButtonModel sourceModel = ((JToggleButton) source).getModel();
			ButtonModel targetModel = ((JToggleButton) target).getModel();
			if ((sourceModel instanceof DefaultButtonModel)
					&& (targetModel instanceof DefaultButtonModel) && (((DefaultButtonModel) sourceModel)
							.getGroup() == ((DefaultButtonModel) targetModel).getGroup())
					&& ((DefaultButtonModel) sourceModel).getGroup() != null) {
				// When toggle buttons are exclusive (that is, they form a
				// radio button set), separate them with 2 pixels. This
				// rule applies whether the toggle buttons appear in a
				// toolbar or elsewhere in the interface.
				// Note: this number does not appear to include any borders
				// and so is not adjusted by the border of the toggle
				// button
				return 2;
			}
			// When toggle buttons are independent (like checkboxes)
			// and used outside a toolbar, separate them with 5
			// pixels.
			if (isOcean) {
				return 6;
			}
			return 5;
		}
		offset = 6;
	} else {
		offset = 12;
	}
	if ((position == SwingConstants.EAST || position == SwingConstants.WEST)
			&& ((sourceCID == "LabelUI" && targetCID != "LabelUI")
					|| (sourceCID != "LabelUI" && targetCID == "LabelUI"))) {
		// Insert 12 pixels between the trailing edge of a
		// label and any associated components. Insert 12
		// pixels between the trailing edge of a label and the
		// component it describes when labels are
		// right-aligned. When labels are left-aligned, insert
		// 12 pixels between the trailing edge of the longest
		// label and its associated component
		return getCBRBPadding(source, target, position, offset + 6);
	}
	return getCBRBPadding(source, target, position, offset);
}
 
Example 5
Source Project: RipplePower   File: GnomeLayoutStyle.java    License: Apache License 2.0 4 votes vote down vote up
public int getPreferredGap(JComponent source, JComponent target, int type, int position, Container parent) {
	// Invoke super to check arguments.
	super.getPreferredGap(source, target, type, position, parent);

	if (type == INDENT) {
		if (position == SwingConstants.EAST || position == SwingConstants.WEST) {
			int gap = getButtonChildIndent(source, position);
			if (gap != 0) {
				return gap;
			}
			// Indent group members 12 pixels to denote hierarchy and
			// association.
			return 12;
		}
		// Treat vertical INDENT as RELATED
		type = RELATED;
	}
	// Between labels and associated components, leave 12 horizontal
	// pixels.
	if (position == SwingConstants.EAST || position == SwingConstants.WEST) {
		boolean sourceLabel = (source.getUIClassID() == "LabelUI");
		boolean targetLabel = (target.getUIClassID() == "LabelUI");
		if ((sourceLabel && !targetLabel) || (!sourceLabel && targetLabel)) {
			return 12;
		}
	}
	// As a basic rule of thumb, leave space between user
	// interface components in increments of 6 pixels, going up as
	// the relationship between related elements becomes more
	// distant. For example, between icon labels and associated
	// graphics within an icon, 6 pixels are adequate. Between
	// labels and associated components, leave 12 horizontal
	// pixels. For vertical spacing between groups of components,
	// 18 pixels is adequate.
	//
	// The first part of this is handled automatically by Icon (which
	// won't give you 6 pixels).
	if (type == RELATED) {
		return 6;
	}
	return 12;
}