이메일

구글 : kdj777ehdwns@gmail.com
네이버 : kdj777ehdwns@naver.com
epsckr2016.blogspot.com

2016년 8월 30일 화요일

[이클립스] 텍스트파일 테스트

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Label;
import java.awt.TextField;
import java.awt.event.ActionListener;
import java.awt.event.TextEvent;
import java.awt.event.TextListener;
import java.awt.event.WindowEvent;

public class TextFieldTest extends Frame
                           implements TextListener, ActionListener {
   TextField tf1;
   Label lbl1;
 
public static void main(String[] args) {
    TextFieldTest f = new TextFieldTest( "텍스트필드 예제" );
f.setSize( 500,500 );
f.setBackground( Color.darkGray );
    f.setVisible( true );
}
 
public TextFieldTest( String t ) {
super ( t );
setLayout ( new FlowLayout() );
tf1 = new TextField( 20 );
tf1.addTextListener( this );
tf1.addActionListener( this );
add( tf1 );
lbl1 = new Label( "글을 입력하시오." );
add( lbl1 );
}

public void textValueChanged( TextEvent e ) {
       lbl1.setText( tf1.getText() );
}

public void actionPerformed( WindowEvent e ) {
  lbl.setText( "완료" );
}
}


날짜 : 2016년 08월 30일

댓글 없음:

댓글 쓰기