티스토리 뷰


public class JTextTest extends JFrame {

JLabel lb, lb1, lb2;

JTextField id;

JPasswordField passwd;

JPanel idPanel, paPanel, loginPanel;

JButton b1, b2;

JTextArea content;


public JTextTest() {

super("JText test");

setLayout(new FlowLayout());

EtchedBorder eborder = new EtchedBorder();


lb = new JLabel("아이디와 패스워드를 입력하세요");

lb.setBorder(eborder);

add(lb); // 메시지를 프레임에 붙임


idPanel = new JPanel();

lb1 = new JLabel("아이디");

id = new JTextField(10);

idPanel.add(lb1);

idPanel.add(id);


// 아이디 패널


paPanel = new JPanel();

lb2 = new JLabel("패스워드");

passwd = new JPasswordField(10);

paPanel.add(lb2);

paPanel.add(passwd);


// 패스워드 패널


loginPanel = new JPanel();

b1 = new JButton("로그인");

b2 = new JButton("회원가입");

loginPanel.add(b1);

loginPanel.add(b2); // 패널에 버튼을 붙임

// 로그인 패널


add(idPanel);

add(paPanel);

add(loginPanel); // 패널들을 프레임에 붙임

content = new JTextArea(5, 20); // 텍스트영역 지정

JScrollPane s = new JScrollPane(content);

// 자체적으로 스크롤이 지원되지 않는 컴포넌트(JTExtArea)를 위한 것

add(s); // JScrollPane을 프레임에 붙임

setSize(250, 350);

setVisible(true);

setDefaultCloseOperation(EXIT_ON_CLOSE);

}


public static void main(String[] args) {

// TODO Auto-generated method stub

new JTextTest();

}

}





'java,web study > 3주차 (7월 15일 ~21일)' 카테고리의 다른 글

Box Layout  (0) 2013.07.17
JComboBox  (0) 2013.07.17
JFrame  (0) 2013.07.17
Card Layout  (0) 2013.07.17
Grid Layout  (0) 2013.07.17
댓글
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
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
글 보관함