Java Code Examples for java.awt.BorderLayout.NORTH

The following are Jave code examples for showing how to use NORTH of the java.awt.BorderLayout class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Logisim   File: Toolbar.java   View Source Code Vote up 6 votes
public void setOrientation(Object value) {
	int axis;
	String position;
	if (value == HORIZONTAL) {
		axis = BoxLayout.X_AXIS;
		position = BorderLayout.LINE_START;
	} else if (value == VERTICAL) {
		axis = BoxLayout.Y_AXIS;
		position = BorderLayout.NORTH;
	} else {
		throw new IllegalArgumentException();
	}
	this.remove(subpanel);
	subpanel.setLayout(new BoxLayout(subpanel, axis));
	this.add(subpanel, position);
	this.orientation = value;
}
 
Example 2
Project: Logisim   File: Frame.java   View Source Code Vote up 5 votes
private void placeToolbar() {
	String loc = AppPreferences.TOOLBAR_PLACEMENT.get();
	Container contents = getContentPane();
	contents.remove(toolbar);
	mainPanelSuper.remove(toolbar);
	if (AppPreferences.TOOLBAR_HIDDEN.equals(loc)) {
		; // don't place value anywhere
	} else if (AppPreferences.TOOLBAR_DOWN_MIDDLE.equals(loc)) {
		toolbar.setOrientation(Toolbar.VERTICAL);
		mainPanelSuper.add(toolbar, BorderLayout.WEST);
	} else { // it is a BorderLayout constant
		Object value = BorderLayout.NORTH;
		for (Direction dir : Direction.cardinals) {
			if (dir.toString().equals(loc)) {
				if (dir == Direction.EAST)
					value = BorderLayout.EAST;
				else if (dir == Direction.SOUTH)
					value = BorderLayout.SOUTH;
				else if (dir == Direction.WEST)
					value = BorderLayout.WEST;
				else
					value = BorderLayout.NORTH;
			}
		}

		contents.add(toolbar, value);
		boolean vertical = value == BorderLayout.WEST || value == BorderLayout.EAST;
		toolbar.setOrientation(vertical ? Toolbar.VERTICAL : Toolbar.HORIZONTAL);
	}
	contents.validate();
}