-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.2
-
x86
-
linux
Name: dk106046 Date: 03/29/2004
OPERATING SYSTEM(S):
Linux ia32
FULL JDK VERSION(S):
1.4.2_03-b02
d348.html
<html>
<head></head>
<body>
<applet code=d348.class width=400 height=350>
</applet>
This test checks that spurious events are not generated.
* Each time you select a number from the Choice component,
the counter for choice should increment by 1, in the TextField.
* Each time you click on the Checkbox (labelled "A"),
the counter for the checkbox should increment by 1.
* If you click on the Button, the Checkbox should become selected
but the checkbox and choice counters should not increment.
</body>
</html>
d348.java
import java.awt.*;
import java.applet.*;
import java.lang.*;
public class d348 extends Applet
{
static String sSCCSid = "@(#)61 1.3 interactive/348/d348.java, regression, regression 7/30/01 15:26:20";
static int choice_counter;
static int check_counter;
Choice choice;
Checkbox checkbox;
Button button;
TextField text;
public void init()
{
choice_counter = 0;
check_counter = 0;
super.init();
setLayout(null);
resize(310,230);
choice = new Choice();
choice.reshape(40,40,112,30);
choice.addItem("0");
choice.addItem("1");
choice.addItem("2");
add(choice);
choice.select(2);
checkbox = new Checkbox("A");
checkbox.reshape(40,65,126,15);
add(checkbox);
button = new Button("OK");
button.reshape(40,85,119,30);
add(button);
text = new TextField();
text.setText("choice " + choice_counter
+ ", checkbox " + check_counter);
text.reshape(40, 130, 180, 30);
add(text);
}
public boolean handleEvent(Event event)
{
System.out.println("EVENT: " + event.toString());
if (event.id == Event.ACTION_EVENT) {
if (event.target == choice)
{
text.setText("choice " + (++choice_counter)
+ ", checkbox " + check_counter);
return true;
}
else if (event.target == checkbox)
{
text.setText("choice " + choice_counter
+ ", checkbox " + (++check_counter));
return true;
}
else if (event.target == button)
{
choice.select(1);
checkbox.setState(true);
return true;
}
}
text.repaint();
return super.handleEvent(event);
}
}
Run the test
appletviewer d348.html
Summary
> When "OK" button is pressed, state is set for "choice" and
"checkbox" but this is being picked up as an ACTION_EVENT
resulting in increment of "choice" counter.
Result:
> When "OK" button is pressed, the "choice" selection is set to
"1" and the "choice" counter is being incremented.
Expected Result:
> When "OK" button is pressed, the "choice" selection is set to
"1" but the checkbox and choice counters should not increment.
======================================================================
- duplicates
-
JDK-4879009 Applet in kaply.com/work/backwards causes appletviewer hang
-
- Resolved
-