/*
 * Created on Jan 5, 2004
 *
 */

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import LumiSoft.UI.Controls.*;

/**
 * 
 */
public class wctrl_WNumericEdit_demo extends JPanel implements ActionListener
{
	private WNumericEdit m_pNumericEdit = null;
	
	public wctrl_WNumericEdit_demo()
	{
		this.setLayout(null);
		
		m_pNumericEdit = new WNumericEdit();
		m_pNumericEdit.setLocation(20,20);
		m_pNumericEdit.setSize(100,22);
		
		//--- Sinners behaviour ---------------------------//
		JRadioButton left = new JRadioButton("Left");
		left.addActionListener(this);
		left.setActionCommand("Spinners_Left");
		
		JRadioButton none = new JRadioButton("None");
		none.addActionListener(this);
		none.setActionCommand("Spinners_None");
		
		JRadioButton right = new JRadioButton("Right");
		right.addActionListener(this);
		right.setSelected(true);
		right.setActionCommand("Spinners_Right");
		
		ButtonGroup sipinnersBehaviour = new ButtonGroup();
		sipinnersBehaviour.add(left);
		sipinnersBehaviour.add(none);
		sipinnersBehaviour.add(right);
		
		JPanel radioPanel = new JPanel(new GridLayout(0,1));
		radioPanel.setLocation(20,50);
		radioPanel.setSize(70,40);
		radioPanel.add(left);
		radioPanel.add(none);
		radioPanel.add(right);
		//-------------------------------------------------------//
		
		//-----------------------------------------------------------
		JRadioButton textAlign_left = new JRadioButton("Left");
		textAlign_left.addActionListener(this);
		textAlign_left.setActionCommand("TextAlign_Left");
		textAlign_left.setSelected(true);
		
		JRadioButton textAlign_right = new JRadioButton("Right");
		textAlign_right.addActionListener(this);
		textAlign_right.setActionCommand("TextAlign_Right");
		
		ButtonGroup gr2 = new ButtonGroup();
		gr2.add(textAlign_left);
		gr2.add(textAlign_right);
		
		JPanel radioPanel2 = new JPanel(new GridLayout(0,1));
		radioPanel2.setLocation(100,50);
		radioPanel2.setSize(100,40);
		radioPanel2.add(textAlign_left);
		radioPanel2.add(textAlign_right);
		//-----------------------------------------------------------
		
		this.add(m_pNumericEdit);
		this.add(radioPanel);
		this.add(radioPanel2);
	}
	
	/** Listens to the radio buttons. */
	public void actionPerformed(ActionEvent e) 
	{//System.out.println(e.getActionCommand());
		if(e.getActionCommand().equals("Spinners_Left")){
			m_pNumericEdit.setSpinnersVisible(true);
			m_pNumericEdit.setSpinnersAlign(LeftRight.Left);
		}
		else if(e.getActionCommand().equals("Spinners_None")){
			m_pNumericEdit.setSpinnersVisible(false);
		}
		else if(e.getActionCommand().equals("Spinners_Right")){
			m_pNumericEdit.setSpinnersVisible(true);
			m_pNumericEdit.setSpinnersAlign(LeftRight.Right);
		}
		else if(e.getActionCommand().equals("TextAlign_Left")){
			m_pNumericEdit.setTextAlign(HorizontalAlignment.Left);			
		}
		else if(e.getActionCommand().equals("TextAlign_Right")){
			m_pNumericEdit.setTextAlign(HorizontalAlignment.Right);			
		}
	}

}
