1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | public class ChatCS extends Frame { private static final long serialVersionUID = 1L; public ChatCS() { addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent arg0) { System.exit( 0 ); //windowClosing : x버튼으로 종료 시 실행됨 } }); } public static void main(String[] args) { new ChatCS(); } } ? |
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 32 33 34 35 36 37 38 39 40 41 42 | public class ChatCS extends Frame implements ActionListener { private static final long serialVersionUID = 1L; private TextField tf; private TextArea ta; public ChatCS() { tf = new TextField(); add(tf, BorderLayout.SOUTH); ta = new TextArea(); add(ta, BorderLayout.CENTER); tf.addActionListener( this ); addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.exit( 0 ); } }); setTitle( "UDP프로그램" ); setSize( 500 , 450 ); setVisible( true ); } public static void main(String[] args) { new ChatCS(); } @Override public void actionPerformed(ActionEvent e) { Component ob = (Component)e.getSource(); if (ob instanceof TextField) { try { String s = tf.getText().trim(); if (s.length() == 0 ) return ; } catch (Exception e2){} } } } |
'java' 카테고리의 다른 글
byte[] ↔ String (0) | 2013.07.25 |
---|---|
byte (0) | 2013.07.25 |
String (0) | 2013.07.25 |
Nested, 중첩클래스 (0) | 2013.07.25 |
FileStream, 파일스트림 (0) | 2013.07.25 |