TextField¿¡¼ FocusÀÇ À̵¿¿¡ µû¸¥ À̺¥Æ®ÀÇ ¹ß»ýÀ» º¸¿©ÁÖ´Â ¿¹Á¦
FocusEventTest.java
import java.awt.*;
import java.awt.event.*;
public class FocusEventTest extends Frame implements FocusListener {
public FocusEventTest(){
super("FocusEvent");
setLayout(new FlowLayout());
Button b1=new Button("¹öư1");
Button b2=new Button("¹öư2");
TextField tf1=new TextField("ÅØ½ºÆ®1");
TextField tf2=new TextField("ÅØ½ºÆ®2");
b1.addFocusListener(this);
b2.addFocusListener(this);
tf1.addFocusListener(this);
tf2.addFocusListener(this);
addFocusListener(this);
add(b1);
add(b2);
add(tf1);
add(tf2);
}
public void focusGained(FocusEvent fe) {
System.out.println(fe);
System.out.println(fe.isTemporary());
}
public void focusLost(FocusEvent fe) {
System.out.println(fe);
System.out.println(fe.isTemporary());
}
public static void main(String[] args) {
Frame f=new FocusEventTest();
f.setSize(200, 100);
f.setVisible(true);
}
}
java.awt.event.FocusEvent[FOCUS_GAINED,permanent] on frame0
false
java.awt.event.FocusEvent[FOCUS_LOST,permanent] on frame0
false
java.awt.event.FocusEvent[FOCUS_GAINED,permanent] on button0
false
java.awt.event.FocusEvent[FOCUS_LOST,permanent] on button0
false
java.awt.event.FocusEvent[FOCUS_GAINED,permanent] on button1
false
java.awt.event.FocusEvent[FOCUS_LOST,permanent] on button1
false
java.awt.event.FocusEvent[FOCUS_GAINED,permanent] on textfield0
false
java.awt.event.FocusEvent[FOCUS_LOST,permanent] on textfield0
false
java.awt.event.FocusEvent[FOCUS_GAINED,permanent] on textfield1
false
java.awt.event.FocusEvent[FOCUS_LOST,temporary] on textfield1
true
Æ÷Ä¿½º À̺¥Æ®´Â ÄÄÆ÷³ÍÆ® À̺¥Æ®¿¡ ¼ÓÇÏ´Â °ÍÀ¸·Î¼ ¸ðµç ÄÄÆ÷³ÍÆ®¿¡ ¹ß»ýÇÒ ¼ö ÀÖ´Â À̺¥Æ®
jabookÀúÀÚ¸íÇÔ |
Á¦¸ñ:¼Ò¼³°°Àº¹Ì´ÏÄÚµå ÀÛ¼ºÀÚ:Àںϸâ¹ö ±è´ë¼º |