| 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 | 
| 9 | 10 | 11 | 12 | 13 | 14 | 15 | 
| 16 | 17 | 18 | 19 | 20 | 21 | 22 | 
| 23 | 24 | 25 | 26 | 27 | 28 | 29 | 
| 30 | 
													Tags
													
											
												
												- 실행시간 측정
 - 초대장
 - 유니옥션
 - react native #gradle
 - visual studio code
 - 티스토리초대
 - Emmet
 - 프리티어
 - GitHub 미러링
 - '티스토리 초대장/ 티스토리초대'
 - webstorm
 - GitLab Mirroring
 - 음료같은녹즙
 - GitLab미러링
 - code 세팅
 - settings sync
 - Path Alias
 - visual studio code cli
 - 프레시업 #풀무원 #하루한병 #건강만들기 #풀무원 녹즙
 - eslint-import-resolver-typescript
 - gitlab 연동
 - currentTimeMillis
 - code 설치
 - code .
 - 티스토리 초대장/ 티스토리초대
 - GitHub Mirroring
 - React Native
 - 티스토리 초대장
 - 네이버 클라우드 플랫폼
 - 니돈내먹
 
													Archives
													
											
												
												- Today
 
- Total
 
방치하기
swing label textfield 본문
반응형
    
    
    
  
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TextFieldTest extends JFrame {
	static String string = "";
	static String string2 = "";
   private JTextField textField1, textField2, textField3;
   public TextFieldTest()
   {
      super( "Testing JTextField and JPasswordField" );
      Container container = this.getContentPane();
      container.setLayout( new GridLayout(3,2) );
      JLabel label=new JLabel("이름");
	  container.add( label );
	  textField1 = new JTextField( 10 );
      container.add( textField1 );
	  JLabel label2=new JLabel("학교");
	  container.add( label2 );
      textField2 = new JTextField( 10 );
      container.add( textField2 );
      JLabel label3=new JLabel("출력");
	  container.add( label3 );
	  textField3 = new JTextField( 10 );
      container.add( textField3 );
      TextFieldHandler handler = new TextFieldHandler();
      
	  textField1.addActionListener( handler );
      textField2.addActionListener( handler );
      textField3.addActionListener( handler );
      setSize( 325, 100 );
      setVisible( true );
   } 
   public static void main( String args[] )
   { 
      TextFieldTest application = new TextFieldTest();
      application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
   }
   // private inner class for event handling
   private class TextFieldHandler implements ActionListener {
      public void actionPerformed( ActionEvent event )
      {
         
		 
		 StringBuffer string3=new StringBuffer();
         if ( event.getSource() == textField1 )
            string = event.getActionCommand();
 
         else if ( event.getSource() == textField2 )
            string2 = event.getActionCommand();
    
         else if ( event.getSource() == textField3 )
		  {
            
			
			/*string3.append("당신의 이름은");
			string3.append(string);
			string3.append("당신의 학교는");
			string3.append(string2);
			JOptionPane.showMessageDialog( null, string3 );*/
			textField3.setText(textField1.getText()+" <이름    학교>"+textField2.getText());
			
		  }
         }
         
      }
}
반응형
    
    
    
  '홍익대 Java > 수업' 카테고리의 다른 글
| 홍대 자바 수업 : 리스트형(스크롤형) 버튼 텍스트 필드 컬러와 배경 색 바꾸기 . (0) | 2009.07.29 | 
|---|---|
| 텍스트 필드와 버튼 (0) | 2009.07.29 | 
| 홍대 자바 수업 : awt 버튼 원하는 자리에 (0) | 2009.07.28 | 
| 홍대 자바 수업 : 패널 (0) | 2009.07.28 | 
| 홍대 자바 수업 : 핵심 플로우 그리드 보더 레이아웃 (0) | 2009.07.28 | 
			  Comments