/*
 * @@COPYRIGHT@@
 */
package com.cosylab.gui.components.wheelswitch;

import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager;

/**
 * Implementation of <code>java.awt.LayoutManager</code> to be used for
 * <code>UpDownButton</code> layout.
 * 
 * @author <a href="mailto:jernej.kamenik@cosylab.com">Jernej Kamenik</a>
 * @version $id$
 */
public class UpDownLayout implements LayoutManager {
	
	/**
	 * @see LayoutManager#addLayoutComponent(String, Component)
	 */
	public void addLayoutComponent(String name, Component comp) {
	}

	/**
	 * @see LayoutManager#removeLayoutComponent(Component)
	 */
	public void removeLayoutComponent(Component comp) {}

	/**
	 * @see LayoutManager#preferredLayoutSize(Container)
	 */
	public Dimension preferredLayoutSize(Container parent) {
		return parent.getPreferredSize();
	}

	/**
	 * @see LayoutManager#minimumLayoutSize(Container)
	 */
	public Dimension minimumLayoutSize(Container parent) {
		return parent.getMinimumSize();
	}

	/**
	 * @see LayoutManager#layoutContainer(Container)
	 */
	public void layoutContainer(Container parent) {
		UpDownButton upDownButton = (UpDownButton)parent;;
		if (upDownButton==null || upDownButton.getComponentCount()!=2) return;		
		int height = upDownButton.getHeight();
		int width = upDownButton.getWidth();
		
		upDownButton.getComponent(0).setBounds(0,0,width,Math.round(height/2f)+1);			
		upDownButton.getComponent(1).setBounds(0,Math.round(height/2f)-1,width,height/2+1);			
		upDownButton.revalidate();
	}	
}

/*
 * @@COPYRIGHT@@
 */
package xal.tools.swing.wheelswitch;

import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager;

/**
 * Implementation of <code>java.awt.LayoutManager</code> to be used for
 * <code>UpDownButton</code> layout.
 * 
 * @author <a href="mailto:jernej.kamenik@cosylab.com">Jernej Kamenik</a>
 * @version $id$
 */
public class UpDownLayout implements LayoutManager {
	
	/**
	 * @see LayoutManager#addLayoutComponent(String, Component)
	 */
	public void addLayoutComponent(String name, Component comp) {
	}

	/**
	 * @see LayoutManager#removeLayoutComponent(Component)
	 */
	public void removeLayoutComponent(Component comp) {}

	/**
	 * @see LayoutManager#preferredLayoutSize(Container)
	 */
	public Dimension preferredLayoutSize(Container parent) {
		return parent.getPreferredSize();
	}

	/**
	 * @see LayoutManager#minimumLayoutSize(Container)
	 */
	public Dimension minimumLayoutSize(Container parent) {
		return parent.getMinimumSize();
	}

	/**
	 * @see LayoutManager#layoutContainer(Container)
	 */
	public void layoutContainer(Container parent) {
		UpDownButton upDownButton = (UpDownButton)parent;;
		if (upDownButton==null || upDownButton.getComponentCount()!=2) return;		
		int height = upDownButton.getHeight();
		int width = upDownButton.getWidth();
		
		upDownButton.getComponent(0).setBounds(0,0,width,Math.round(height/2f)+1);			
		upDownButton.getComponent(1).setBounds(0,Math.round(height/2f)-1,width,height/2+1);			
		upDownButton.revalidate();
	}	
}

Update package for 'UpDownLayout'.