|
Quick Lists
|
|
Bug ID:
|
4028580
|
|
Votes
|
3
|
|
Synopsis
|
TextArea does not send TextEvent when setText. Does for insert
|
|
Category
|
java:classes_awt
|
|
Reported Against
|
1.1.1
, kestrel
, 1.1beta3
, merlin-beta
|
|
Release Fixed
|
1.5(tiger-b28)
|
|
State
|
10-Fix Delivered,
bug
|
|
Priority:
|
4-Low
|
|
Related Bugs
|
4040127
,
4503516
,
4948034
|
|
Submit Date
|
28-JAN-1997
|
|
Description
|
Have listener for TextEvent on TextArea. No event generated
for setText. Is generated for insert. setText is generated for TextField
though.
======================================================================
You may close this bug because I found out that this is currently working
for jdk1.3 version V, and jdk1.4. Moreover, the TextValueListener is running
as a different thread than the main program so some time has to be given so
that it can respond. The following sample program prove it.
Roger Pham 3/9/2000
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class ta implements TextListener {
public static void main(String argv[]) {
new ta();
}
ta() {
Frame f = new Frame("test");
TextArea t = new TextArea("", 10, 30);
t.addTextListener(this);
f.add(t);
f.setSize(300, 200);
f.pack();
f.setVisible(true);
t.setText("Hello ");
t.append(" World! ");
t.insert("from Roger Pham", 13);
t.replaceRange("Java Duke", 17, 28);
try {
Thread.sleep(60000);
} catch (InterruptedException e) {}
System.exit(0);
}
public void textValueChanged(TextEvent e) {
TextArea ta = (TextArea) e.getSource();
System.out.println ("Got TextEvent " + ta.getText());
}
}
----------------------------------------------------------------------
Upon further testing, I found the above program fail on Win'95, WinNT
Roger Pham 3/9/2000
|
|
Work Around
|
Could override setText.
======================================================================
|
|
Evaluation
|
Evaluated
======================================================================
This bug exists only on Win32
======================================================================
The bug is still reproducible under WinNT 4.0 SP5 with JDK 1.3RA
xxxxx@xxxxx 1999-11-24
Commit to fix in Hopper (JCK-exclude).
xxxxx@xxxxx 2001-12-02
WTextComponentPeer.valueChanged() posts a TextEvent. It is called from
./awt_TextComponent.cpp(217): DoCallback("valueChanged", "()V");
./awt_TextArea.cpp(453): DoCallback("valueChanged", "()V");
in the WmNotify method for both files.
MTextAreaPeer and MTextFieldPeer have valueChanged methods identical to the one
in WTextComponentPeer. However, I only see them being called from
./awt_TextField.c(203): "valueChanged", "()V");
in the Text_valueChanged method. This method is declared extern in
awt_TextArea.c. They are added as callbacks on widget creation.
WTextComponentPeer has setText only as a native method.
./awt_TextComponent.cpp(417): Java_sun_awt_windows_WTextComponentPeer_setText
It calls this method on initialization. Should see whether TextEvents are sent
on peer creation on Solaris and Windows - make them consistent, specify this?
I wonder if TextField.setText generated a TextEvent? Should check this.
Oddly, TextArea has an insert method, but TextField does not.
Java_sun_awt_windows_WTextAreaPeer_insertText doesn't do anything but call
Java_sun_awt_windows_WTextAreaPeer_replaceText
Theory: the c->SendMessageW(EM_REPLACESEL message sent in replaceText()
triggers WmNotify, which posts the TextEvent.
Java_sun_awt_windows_WTextComponentPeer_setText(JNIEnv *env, jobject self,
just calls c->SetText(buffer). Perhaps it doesn't send a message, so it
doesn't trigger the WmNotify. If this is the case, we should post the message
from Java_sun_awt_windows_WTextComponentPeer_setText.
xxxxx@xxxxx 2002-02-01
Should also see 4503516.
xxxxx@xxxxx 2002-06-12
Due to investigation, except mentioned in the bug report, I have
found that there is one more inconsistency in the behavior across
platforms. It manifests with XToolkit only. If a TextArea has an
empty text and we set an empty string as a text, by calling
setText(""), XToolkit generates a text event. MToolkit and
Windows toolkit do not do that. Considering binary compatibility
issues I fixed XToolkit.
Here is a brief summary of the current (non-fixed) behavior.
----------------------------------------------------------------------
| | setText("some_text") | setText("") |
+---------+------------------------+---------------------------------+
|Win32 | TextEvent triggered | (1)TextEvent does not triggered |
| | | |
|XToolkit | TextEvent triggered | TextEvent triggered |
| | | |
|MToolkit | (2)TextEvent triggered | (1)TextEvent does not triggered |
----------------------------------------------------------------------
(1) If a text is empty and setText("") is called.
(2) The TextEvent triggers only if a TextArea is initialized with
non-empty text passed into its constructor.
The fix is based on workaround for a Motif "feature":
Motif does not generate any event if a text widget was set up
with an empty text string (or widget's text was not initialized
at all) and we change it with an empty text string.
Please see the Suggested fix.
The TextField component works the same across platforms. There is
a difference between TextArea and TextField, though. TextField
generates a text event when its empty text is replaced by an
empty text. In other words, we have a text event for each
setText("") call.
xxxxx@xxxxx 2003-10-22
======================================================================
|
|
Comments
|
Submitted On 04-NOV-1999
gaillard
This is _still_ a bug in 1.3beta. C'mon already, fix it.
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |