All Downloads are FREE. Search and download functionalities are using the official Maven repository.

se.wfh.libs.common.gui.AbstractWTextField Maven / Gradle / Ivy

There is a newer version: 0.17
Show newest version
package se.wfh.libs.common.gui;

import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

import javax.swing.JTextField;

public abstract class AbstractWTextField extends
		AbstractWValidatingComponent implements FocusListener {
	private static final long serialVersionUID = 1L;

	public AbstractWTextField() {
		this(null, 20);
	}

	public AbstractWTextField(final E defval) {
		this(defval, 20);
	}

	public AbstractWTextField(final E defval, final int columns) {
		super(defval, new JTextField(defval == null ? "" : defval.toString(),
				columns));

		getComponent().addFocusListener(this);
	}

	@Override
	public void focusGained(final FocusEvent event) {
		// not needed
		event.getID(); // for PMD
	}

	@Override
	public void focusLost(final FocusEvent event) {
		valueChanged(getValue());
	}

	public boolean isEditable() {
		return getComponent().isEditable();
	}

	public void setEditable(final boolean editable) {
		getComponent().setEditable(editable);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy