자바/채팅방
채팅방 Client UI
행복한 수지아빠
2010. 10. 21. 16:00
반응형
import javax.swing.*;
import java.awt.*;
public class ChattingClient
{
public static void main(String[] args)
{
CreateChattingUI ccu =new CreateChattingUI();
ccu.setSize(500,500);
ccu.pack();
ccu.setVisible(true);
}
}
//채팅방UI 만드는 클래스
class CreateChattingUI extends JFrame
{
JPanel jp,bottom_jp;
BorderLayout bl;
JTextArea top_jta,member_jta;
JTextField username_jtf,msg_jtf;
JButton msgSend_jb;
public CreateChattingUI()
{
super("자바로 만든 채팅방");
this.setLayout(new BorderLayout());
jp = new JPanel();
bl = new BorderLayout(2,2);
top_jta = new JTextArea();//왼쪽위 텍스트창
member_jta = new JTextArea(2,12);
username_jtf = new JTextField("대화명",10);
msg_jtf = new JTextField("메세지를 입력하시길 바랍니다.",42);
bottom_jp = new JPanel(new FlowLayout());
msgSend_jb = new JButton("메세지보내기");
/*
textarea에 스크롤 붙이기
*/
JScrollPane scrollPane = new JScrollPane();
scrollPane.setPreferredSize(new Dimension(600,300));
scrollPane.setBorder(BorderFactory.createTitledBorder(""));
scrollPane.getViewport().add(top_jta, null);
jp.setLayout(bl);
jp.add(scrollPane,BorderLayout.WEST);
jp.add(member_jta,BorderLayout.EAST);
//msg_jtf.setSize(350,30);
bottom_jp.add(username_jtf);
bottom_jp.add(msg_jtf);
bottom_jp.add(msgSend_jb);
this.add(jp,BorderLayout.NORTH);
this.add(bottom_jp,BorderLayout.SOUTH);
}
}
반응형