/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dowser.model;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

/**
 *
 * @author Chetan Pawgi
 */
public class TextRestrictor extends KeyAdapter {

	@Override
	public void keyTyped(KeyEvent e) {

		char ch = e.getKeyChar();
		if (!e.isActionKey() && e.getKeyChar() != '_' && e.getKeyChar() != ' ' && e.getKeyChar() < 'a' || e.getKeyChar() > 'z') {
			e.consume();
			return;
		}
		if (e.isShiftDown() && Character.isDefined(e.getKeyCode())) {
			e.setKeyChar(Character.toLowerCase(ch));
		}
		if (Character.isUpperCase(ch)) {
			e.setKeyChar(Character.toLowerCase(ch));

		}
	}
}
