채팅UI 2010.7.29

javabasic 2010. 7. 30. 19:39

//2010.7.29 VER1.00
package sms.it;

import java.awt.*;
import java.awt.event.*;

class Exam_02_Sub extends Frame implements ActionListener {
 String str1="========================================================" +"\n"
       +"채팅 방에 오신것을 환영합니다.즐거운 시간되세요!!!!" + "\n"
       + "========================================================"+"\n";
 String str2="[방 참가인원]";
 
 private BorderLayout bl_a=new BorderLayout();
 private BorderLayout bl_change=new BorderLayout();//dlg_change
 private BorderLayout bl_send=new BorderLayout();//dlg_send
 
 private FlowLayout fl_change=new FlowLayout();
 private FlowLayout fl_send=new FlowLayout();
 private FlowLayout fl_send2=new FlowLayout();
 
 private Label label_a=new Label("부산IT직업학교 채팅프로그램입니다.");
 private Label label_color=new Label("색상선택");
 private Label label_change=new Label("바꿀 대화명:");
 private Label label_send1=new Label("대화명:");
 private Label label_send2=new Label("보낼 내용:");
 
 private Panel panel_south=new Panel();
 private Panel panel_north=new Panel();
 private Panel panel_east=new Panel();
 private Panel panel_center=new Panel();
 private Panel panel_south_sub1=new Panel();
 private Panel panel_south_sub2=new Panel();
 private Panel panel_change1=new Panel();//dlg_change
 private Panel panel_change2=new Panel();//dlg_change
 private Panel panel_send1=new Panel();//dlg_send
 private Panel panel_send2=new Panel();//dlg_send
 private Panel panel_send3=new Panel();//dlg_send
 
 private GridLayout gl_south=new GridLayout(2,1);
 private GridLayout glb_change=new GridLayout(2,1);//dlg_change
 private GridLayout glb_send=new GridLayout(3,1);//dlg_send
 
 private Choice choice_whisper=new Choice();
 private Choice choice_color=new Choice();
 
 private TextArea text_center=new TextArea(str1,30,70);
 private TextArea text_east=new TextArea(str2,30,20);
 private TextField text_south=new TextField("",40);
 private TextField text_change=new TextField("",10);
 private TextField text_send1=new TextField("",10);
 private TextField text_send2=new TextField("",40);
 
 private Button btn_eraser=new Button("화면지우기");
 private Button btn_help=new Button("도움말");
 private Button btn_exit=new Button("나가기");
 private Button btn_msg=new Button("쪽지보내기");
 private Button btn_change=new Button("대화명바꾸기");
 private Button btn_end=new Button("방나가기");
 private Button btn_dlg_ok=new Button("완료");
 private Button btn_dlg_cancel1=new Button("취소");
 private Button btn_dlg_send=new Button("보내기");
 private Button btn_dlg_cancel2=new Button("취소하기");
 //Dialog
 private Dialog dlg_change=new Dialog(this,"대화명 바꾸기",true);
 private Dialog dlg_send=new Dialog(this,"쪽지보내기",true);
 
 
 public Exam_02_Sub(String title){
  super(title);
  
  this.init();
  this.start();//event,thread adding
  
  this.setSize(800, 600);
  Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();
  Dimension frm=super.getSize();
  int xpos=(int)(screen.getWidth()/2-frm.getWidth()/2);
  int ypos=(int)(screen.getHeight()/2-frm.getHeight()/2);
  super.setLocation(xpos,ypos);
  super.setResizable(false);
  super.setVisible(true);
 
 }
 public void init(){
    
  this.setLayout(bl_a);
    
  panel_north.add(label_a);
  this.add("North",panel_north);
  panel_north.setBackground(new Color(150,135,0));
  
  panel_south.setLayout(gl_south);
  choice_whisper.add("귓속말선택");
  panel_south_sub1.add(choice_whisper);
  panel_south_sub1.add(text_south);
  panel_south_sub1.add(btn_eraser);
  panel_south_sub1.add(btn_help);
  panel_south_sub1.add(btn_exit);
  panel_south.add(panel_south_sub1);
  panel_south_sub2.add(label_color);
  choice_color.add("빨강");
  choice_color.add("파랑");
  choice_color.add("노랑");
  choice_color.add("녹색");
  panel_south_sub2.add(choice_color);
  panel_south_sub2.add(btn_msg);
  panel_south_sub2.add(btn_change);
  panel_south_sub2.add(btn_end);
  panel_south.add(panel_south_sub2);
  this.add("South",panel_south);
  panel_south.setBackground(new Color(150,135,0));
  
  panel_east.add(text_east);
  this.add("East",panel_east);
  
  
  this.add("Center",text_center);
  
  
  //dialog_change
  dlg_change.setLayout(bl_change);
  panel_change1.setLayout(fl_change);
  panel_change1.add(label_change);
  panel_change1.add(text_change);
  panel_change2.add(btn_dlg_ok);
  panel_change2.add(btn_dlg_cancel1);
  dlg_change.add("North",panel_change1);
  dlg_change.add("South",panel_change2);
  
  //dialog_send
  dlg_send.setLayout(bl_send);
  dlg_send.setLayout(glb_send);
  panel_send1.setLayout(fl_send);
  panel_send2.setLayout(fl_send2);
  panel_send1.add(label_send1,"LEFT");
  panel_send1.add(text_send1);
  panel_send2.add(label_send2);
  panel_send2.add(text_send2);
  panel_send3.add(btn_dlg_send);
  panel_send3.add(btn_dlg_cancel2);
  dlg_send.add("North",panel_send1);
  dlg_send.add("Center",panel_send2);
  dlg_send.add("South",panel_send3);
  
  this.setVisible(true);
  
 }
 public void start(){
  btn_eraser.addActionListener(this);
  btn_help.addActionListener(this);
  btn_exit.addActionListener(this);
  btn_msg.addActionListener(this);
  btn_change.addActionListener(this);
  btn_end.addActionListener(this);
  btn_dlg_ok.addActionListener(this);
  btn_dlg_cancel1.addActionListener(this);
  btn_dlg_send.addActionListener(this);
  btn_dlg_cancel2.addActionListener(this);
  
  this.addWindowListener(new WindowAdapter() {
   public void windowClosing(WindowEvent e){
    System.exit(0);
   }
  });
  dlg_change.addWindowListener(new WindowAdapter() {
   public void windowClosing(WindowEvent e){
    dlg_change.setVisible(false);
   }
  });
  dlg_send.addWindowListener(new WindowAdapter() {
   public void windowClosing(WindowEvent e){
    dlg_send.setVisible(false);
   }
  });
 }
 public void actionPerformed(ActionEvent e){
  if(e.getSource()==btn_eraser){
   
  }
  else if(e.getSource()==btn_help){
   
  }
  else if(e.getSource()==btn_exit){
   System.exit(0);
  }
  else if(e.getSource()==btn_msg){
   dlg_send.setLocation(200, 400);
   dlg_send.setSize(400,160);
   dlg_send.setVisible(true);
  }
  else if(e.getSource()==btn_change){
   dlg_change.setLocation(200, 200);
   dlg_change.setSize(200,120);
   dlg_change.setVisible(true);
  }
  else if(e.getSource()==btn_end){
   
  }
  else if(e.getSource()==btn_dlg_ok){
   
  }
  else if(e.getSource()==btn_dlg_cancel1){
   dlg_change.setVisible(false);
  }
  else if(e.getSource()==btn_dlg_send){
   
  }
  else if(e.getSource()==btn_dlg_cancel2){
   dlg_send.setVisible(false);
  }
  
 }
 
}

public class ChattingProgram {

 public static void main(String[] args) {
  Exam_02_Sub ex=new Exam_02_Sub("채팅 프로그램");

 }

}


 
 

'javabasic' 카테고리의 다른 글

채팅ver1.05  (0) 2010.08.04
chatting ver1.02  (0) 2010.08.04
chatting-frame ui  (0) 2010.07.23
채팅 UI  (0) 2010.07.22
자바강의2  (0) 2010.07.22
Posted by 지화명이
,