| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 31 |
Tags
- 실행시간 측정
- code 설치
- visual studio code
- 네이버 클라우드 플랫폼
- 프레시업 #풀무원 #하루한병 #건강만들기 #풀무원 녹즙
- react native #gradle
- currentTimeMillis
- React Native
- '티스토리 초대장/ 티스토리초대'
- 니돈내먹
- webstorm
- 티스토리 초대장
- GitLab Mirroring
- gitlab 연동
- settings sync
- 유니옥션
- GitHub 미러링
- code .
- code 세팅
- GitHub Mirroring
- GitLab미러링
- 음료같은녹즙
- Emmet
- visual studio code cli
- 티스토리초대
- eslint-import-resolver-typescript
- 티스토리 초대장/ 티스토리초대
- 프리티어
- 초대장
- Path Alias
Archives
- Today
- Total
방치하기
텍스트 필드와 버튼 본문
반응형
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Add extends JFrame {
private JButton addButton, printButton;
Panel pan01,pan02;
JTextField text01,text02;
StringBuffer str=new StringBuffer();
public Add()
{
super( "이름추가" );
text01 = new JTextField( 5 );
text02 = new JTextField( 10 );
text02.setEditable(false);
Container container = getContentPane();
container.setLayout(new GridLayout(2,1));
addButton = new JButton( "추가" );
printButton = new JButton( "출력" );
pan01=new Panel();
pan02=new Panel();
container.add( pan01 );
container.add( pan02 );
pan01.setLayout(new BorderLayout());
pan01.add(BorderLayout.WEST,text01);
pan01.add(BorderLayout.EAST,addButton);
pan01.setLayout(new GridLayout(1,2));
pan02.setLayout(new BorderLayout());
pan02.add(BorderLayout.NORTH,text02);
pan02.add(BorderLayout.SOUTH,printButton);
ButtonHandler handler = new ButtonHandler();//액션이 발생하면 아래 내부 클래스로 넘김
addButton.addActionListener( handler );
printButton.addActionListener( handler );
setSize( 275, 150 );
setVisible( true );
}
public static void main( String args[] )
{
Add application = new Add();
application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}
private class ButtonHandler implements ActionListener {
public void actionPerformed( ActionEvent event )
{
if("추가".equals(event.getActionCommand()))
{
JOptionPane.showMessageDialog(Add.this,
"You pressed: " + text01.getText()+"추가합니다" );
str.append(text01.getText()+" ");
System.out.println(text01.getText()+"추가합니다");
text01.setText("");
}
else
{
String str02= str.substring(0);
System.out.println(str02);
text02.setText(str02);
}
}
}
}
반응형
'홍익대 Java > 수업' 카테고리의 다른 글
| 홍대 자바 수업 계산기임 Model / View /Control Float.parseFloat (0) | 2009.07.30 |
|---|---|
| 홍대 자바 수업 : 리스트형(스크롤형) 버튼 텍스트 필드 컬러와 배경 색 바꾸기 . (0) | 2009.07.29 |
| swing label textfield (0) | 2009.07.28 |
| 홍대 자바 수업 : awt 버튼 원하는 자리에 (0) | 2009.07.28 |
| 홍대 자바 수업 : 패널 (0) | 2009.07.28 |
Comments