本文整理汇总了Java中java.awt.event.TextListener类的典型用法代码示例。如果您正苦于以下问题:Java TextListener类的具体用法?Java TextListener怎么用?Java TextListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextListener类属于java.awt.event包,在下文中一共展示了TextListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addTextListener
import java.awt.event.TextListener; //导入依赖的package包/类
/**
* Adds a new listener to the list of text listeners for this
* component.
*
* @param listener The listener to be added.
*/
public synchronized void addTextListener(TextListener listener)
{
textListener = AWTEventMulticaster.add(textListener, listener);
enableEvents(AWTEvent.TEXT_EVENT_MASK);
}
示例2: processTextEvent
import java.awt.event.TextListener; //导入依赖的package包/类
protected void processTextEvent(TextEvent e) {
for (TextListener listener : textListeners.getUserListeners()) {
switch (e.getID()) {
case TextEvent.TEXT_VALUE_CHANGED:
listener.textValueChanged(e);
break;
}
}
}
示例3: testAddRemoveTextListener
import java.awt.event.TextListener; //导入依赖的package包/类
public void testAddRemoveTextListener() {
textComp.addTextListener(listener);
assertSame(listener, textComp.textListener);
TextListener newListener = new MyTextListener();
textComp.addTextListener(newListener);
assertTrue("if there are several listeners multicaster is used",
textComp.textListener instanceof AWTEventMulticaster);
AWTEventMulticaster aem = (AWTEventMulticaster) textComp.textListener;
assertSame(listener, aem.a);
textComp.removeTextListener(listener);
assertTrue("if there is only one listener then it is used",
textComp.textListener instanceof MyTextListener);
assertSame(newListener, textComp.textListener);
textComp.removeTextListener(newListener);
assertNull(textComp.textListener);
}
示例4: addListeners
import java.awt.event.TextListener; //导入依赖的package包/类
protected void addListeners( final GenericDialog gd, final TextField tf, final Label label1, final Label label2 )
{
final GenericLoadParseQueryXML< ?,?,?,?,?,? > lpq = this;
// using TextListener instead
tf.addTextListener( new TextListener()
{
@Override
public void textValueChanged( final TextEvent t )
{
if ( t.getID() == TextEvent.TEXT_VALUE_CHANGED )
{
final String xmlFilename = tf.getText();
// try parsing if it ends with XML
tryParsing( xmlFilename, false );
label1.setText( lpq.message1 );
label2.setText( lpq.message2 );
label1.setForeground( lpq.color );
label2.setForeground( lpq.color );
}
}
});
}
示例5: addTextListener
import java.awt.event.TextListener; //导入依赖的package包/类
/**
* Maps {@code TextComponent.addTextListener(TextListener)} through queue
*/
public void addTextListener(final TextListener textListener) {
runMapping(new MapVoidAction("addTextListener") {
@Override
public void map() {
((TextComponent) getSource()).addTextListener(textListener);
}
});
}
示例6: removeTextListener
import java.awt.event.TextListener; //导入依赖的package包/类
/**
* Maps {@code TextComponent.removeTextListener(TextListener)} through queue
*/
public void removeTextListener(final TextListener textListener) {
runMapping(new MapVoidAction("removeTextListener") {
@Override
public void map() {
((TextComponent) getSource()).removeTextListener(textListener);
}
});
}
示例7: addTextListener
import java.awt.event.TextListener; //导入依赖的package包/类
/**
* Adds a new listener to the list of text listeners for this
* component.
*
* @param listener The listener to be added.
*/
public synchronized void addTextListener(TextListener listener)
{
textListener = AWTEventMulticaster.add(textListener, listener);
enableEvents(AWTEvent.TEXT_EVENT_MASK);
}
示例8: fireTextEvent
import java.awt.event.TextListener; //导入依赖的package包/类
private static void fireTextEvent() {
EventListener[] lstrs =
EVENT_LISTENER_LIST.getListeners(TextListener.class);
if (lstrs != null && lstrs.length > 0) {
TextEvent te =
new TextEvent(FIND_REPLACE_DIALOG, TextEvent.TEXT_VALUE_CHANGED);
for (int i = 0; i < lstrs.length; i++) {
((TextListener) lstrs[i]).textValueChanged(te);
}
}
}
示例9: createViewOne
import java.awt.event.TextListener; //导入依赖的package包/类
private JPanel createViewOne(MenuController menuController) {
JPanel pnl = createFormularPanel();
//
TextListener textActionListener = new TextListener() {
public void textValueChanged(TextEvent e) {
enableButtons();
}
};
namesInputForm = new NamesFormularPanel(menuController.trans, textActionListener);
namesInputForm.setLocation(2, 10);
pnl.add(namesInputForm);
//
return pnl;
}
示例10: NamesFormularPanel
import java.awt.event.TextListener; //导入依赖的package包/类
public NamesFormularPanel(Translator trans, TextListener al) {
super();
//
setLayout(null);
setSize(new Dimension(224, 90));
setBackground(Color.WHITE);
setForeground(Color.BLACK);
//
// text input fields
nameOfPlayerTxtField = new TextField();
nameOfPlayerTxtField.addTextListener(al);
nameOfPlayerTxtField.setFont(systemFont);
nameOfPlayerTxtField.setBounds(5, 5, 210, 22);
add(nameOfPlayerTxtField);
//
nameOfPartyTxtField = new TextField();
nameOfPartyTxtField.addTextListener(al);
nameOfPartyTxtField.setFont(systemFont);
nameOfPartyTxtField.setBounds(5, 50, 210, 22);
add(nameOfPartyTxtField);
//
// ... and their labels
JLabel lbl = new JLabel(trans.word("menu.settings.namePlayer"));
lbl.setBounds(5, 25, 210, 20);
lbl.setFont(SettingsPanel.cursiveFont);
add(lbl);
//
lbl = new JLabel(trans.word("menu.settings.nameParty"));
lbl.setBounds(5, 70, 210, 20);
lbl.setFont(SettingsPanel.cursiveFont);
add(lbl);
}
示例11: textValueChanged
import java.awt.event.TextListener; //导入依赖的package包/类
public void textValueChanged(TextEvent e) {
if ((a != null) && (a instanceof TextListener)) {
((TextListener) a).textValueChanged(e);
}
if ((b != null) && (b instanceof TextListener)) {
((TextListener) b).textValueChanged(e);
}
}
示例12: getListeners
import java.awt.event.TextListener; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
if (TextListener.class.isAssignableFrom(listenerType)) {
return (T[]) getTextListeners();
}
return super.getListeners(listenerType);
}
示例13: testGetListeners
import java.awt.event.TextListener; //导入依赖的package包/类
public void testGetListeners() {
Class<TextListener> cls = TextListener.class;
EventListener[] listeners = textComp.getListeners(cls);
assertEquals(0, listeners.length);
textComp.addTextListener(listener);
assertEquals(1, (listeners = textComp.getListeners(cls)).length);
assertSame(listener, listeners[0]);
}
示例14: testGetTextListeners
import java.awt.event.TextListener; //导入依赖的package包/类
public void testGetTextListeners() {
TextListener[] listeners = textComp.getTextListeners();
assertEquals(0, listeners.length);
textComp.addTextListener(listener);
assertEquals(1, (listeners = textComp.getTextListeners()).length);
assertSame(listener, listeners[0]);
}
示例15: addTextListener
import java.awt.event.TextListener; //导入依赖的package包/类
/**
* Adds a TextListener event listener.
*
* @param listener The listener to add.
*
* @see #removeTextListener
*/
public void addTextListener(TextListener listener) {
// is there anything to do?
if (listener == null)
return;
if (textListeners == null)
textListeners = new Vector();
// add listener
textListeners.addElement(listener);
}