FOCUS_IN and FOCUS_OUT aren;'t reported on Button, TexField, TextArea at
least using JDK1.0.2 on Win 32.
On Solaris they are reported.
Not sure for the reason for this anomaly but I think they are supposed to be
consistent
Here is a test program.
import java.awt.*;
import java.applet.*;
import java.lang.*;
import java.io.*;
public final class eventTest extends Applet {
InputTextField inputField; // single-linetype-in area;
InputTextArea inputArea; // multi-line type-in area
public eventTest() {
}
public static void main(String args[]) {
Frame f = new Frame("Event Test");
eventTest eT = new eventTest();
eT.init();
eT.start();
f.add("Center", eT);
f.resize(300,200);
f.show();
}
public void init() {
Panel p = new Panel();
p.setLayout(new BorderLayout());add(p);
inputArea = new InputTextArea("", 4,20);
p.add("Center",inputArea);
inputField = new InputTextField("", 20);
p.add("South",inputField);
InputButton b = new InputButton();
p.add("North", b);
}
}
class InputButton extends Button {
public InputButton() {
super("Press Me");
}
public boolean handleEvent(Event e) {
System.out.println("caught Button event");
if (e.id == Event.GOT_FOCUS)
System.out.println("Button Focus In");
else if (e.id == Event.LOST_FOCUS)
System.out.println("Button Focus Out");
return super.handleEvent(e);
}
}
class InputTextField extends TextField {
public InputTextField(String s, int cols) {
super(s,cols);
}
public boolean handleEvent(Event e) {
System.out.println("caught TextField event");
if (e.id == Event.GOT_FOCUS)
System.out.println("TextField Focus In");
else if (e.id == Event.LOST_FOCUS)
System.out.println("TextField Focus Out");
return super.handleEvent(e);
}
}
class InputTextArea extends TextArea {
public InputTextArea(String s, int rows, int cols) {
super(s,rows,cols);
}
public boolean handleEvent(Event e) {
System.out.println("caught TextArea event");
if (e.id == Event.GOT_FOCUS)
System.out.println("TextArea Focus In");
else if (e.id == Event.LOST_FOCUS)
System.out.println("TextArea Focus Out");
return super.handleEvent(e);
}
}
least using JDK1.0.2 on Win 32.
On Solaris they are reported.
Not sure for the reason for this anomaly but I think they are supposed to be
consistent
Here is a test program.
import java.awt.*;
import java.applet.*;
import java.lang.*;
import java.io.*;
public final class eventTest extends Applet {
InputTextField inputField; // single-linetype-in area;
InputTextArea inputArea; // multi-line type-in area
public eventTest() {
}
public static void main(String args[]) {
Frame f = new Frame("Event Test");
eventTest eT = new eventTest();
eT.init();
eT.start();
f.add("Center", eT);
f.resize(300,200);
f.show();
}
public void init() {
Panel p = new Panel();
p.setLayout(new BorderLayout());add(p);
inputArea = new InputTextArea("", 4,20);
p.add("Center",inputArea);
inputField = new InputTextField("", 20);
p.add("South",inputField);
InputButton b = new InputButton();
p.add("North", b);
}
}
class InputButton extends Button {
public InputButton() {
super("Press Me");
}
public boolean handleEvent(Event e) {
System.out.println("caught Button event");
if (e.id == Event.GOT_FOCUS)
System.out.println("Button Focus In");
else if (e.id == Event.LOST_FOCUS)
System.out.println("Button Focus Out");
return super.handleEvent(e);
}
}
class InputTextField extends TextField {
public InputTextField(String s, int cols) {
super(s,cols);
}
public boolean handleEvent(Event e) {
System.out.println("caught TextField event");
if (e.id == Event.GOT_FOCUS)
System.out.println("TextField Focus In");
else if (e.id == Event.LOST_FOCUS)
System.out.println("TextField Focus Out");
return super.handleEvent(e);
}
}
class InputTextArea extends TextArea {
public InputTextArea(String s, int rows, int cols) {
super(s,rows,cols);
}
public boolean handleEvent(Event e) {
System.out.println("caught TextArea event");
if (e.id == Event.GOT_FOCUS)
System.out.println("TextArea Focus In");
else if (e.id == Event.LOST_FOCUS)
System.out.println("TextArea Focus Out");
return super.handleEvent(e);
}
}