티스토리 뷰


이번 포스팅에서는

회원가입 기능을

설계해보도록 하겠습니다.

회원가입부터는 서버를 이용해 데이터를 전송하기 때문에

여러가지 변수에 따라 

알맞게 처리해주어야합니다.


===========================================================================================


5. Rhythm Game : Signup






1. Rhythm Game : Signup


 사용자가 회원가입을 한다면 해당 아이디를 서버에서 저장하고 저장한 데이터를 이용해 언제든지 사용자가 접속할 수 있어야합니다. 또한 서버가 재시작된다 하더라도 사용자의 정보는 그대로 남게 있어야합니다.

 보통 사용자의 정보를 저장하기 위해 DB를 사용하지만 자바의 기능만을 이용해 구현하는 것을 바탕으로 두기 떄문에 파일 입출력을 통해 유저들의 정보를 저장하고 관리하겠습니다.


 아이디 찾기와 비밀번호 찾기의 기능은 설계하지 않을 것이지만 사용자의 입력 변수에 따라 로그인 패널과 회원가입 패널에서 처리하는 작업을 진행하도록 하겠습니다.






2. Rhythm Game : LoginPanel.java


 먼저 로그인 패널입니다. 

로그인 패널은 로딩창(WelcomPanel)이 종료되면 나오는 패널이기 때문에 ClientUI에서 돌아가고 있는 쓰레드를 종료시킨 후 프레임의 패널을 로그인 패널로 설정해 주면 됩니다.


Graphic을 통해 배경화면에 움짤을 넣어주었고, 로그인에 필요한 아이디, 비밀번호 입력 필드와 로그인, 회원가입을 위한 버튼 2개를 만들었습니다.



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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package clientPanel;
 
import java.awt.Color;
...
 
public class LoginPanel extends JPanel {
    public JTextField tfid;
    public JButton btlogin;
    public JButton btsign;
    public JPasswordField tfpw;
    public JLabel logo;
    private Graphics screenGraphic;
    private Image panelImage;
    private Image selectedImage ;
    private Image backgroundImage = new ImageIcon(getClass().getResource("imge/123.gif")).getImage();
 
    public LoginPanel() {
        init();
    }
    
    private void init() {
        setSize(496748);
        setLayout(null);
        
        // 상단 로고 이미지 ===========================================================
        logo = new JLabel("");
        logo.setBounds(125178243203);
        URL url;
            url = getClass().getResource("imge/logo.png");
        logo.setIcon(new ImageIcon(url));
        add(logo);
        // ===========================================================================
 
        // ID 입력 필드 ===============================================================
        tfid = new JTextField();
        tfid.setBounds(25245311624);
        add(tfid);
        tfid.setColumns(10);
        // ===========================================================================
        
        // PW 입력 필드 ===============================================================
        tfpw = new JPasswordField();
        tfpw.setBounds(25250811624);
        add(tfpw);
        // ===========================================================================
        
        // 라벨 ======================================================================
        JLabel lblNewLabel_1 = new JLabel("\uC544\uC774\uB514 : ");
        lblNewLabel_1.setForeground(Color.WHITE);
        lblNewLabel_1.setHorizontalAlignment(SwingConstants.RIGHT);
        lblNewLabel_1.setFont(new Font("함초롬바탕", Font.BOLD | Font.ITALIC, 15));
        lblNewLabel_1.setBounds(1674556218);
        add(lblNewLabel_1);
        
        JLabel lblNewLabel_2 = new JLabel("\uD328\uC2A4\uC6CC\uB4DC : ");
        lblNewLabel_2.setForeground(Color.WHITE);
        lblNewLabel_2.setHorizontalAlignment(SwingConstants.RIGHT);
        lblNewLabel_2.setFont(new Font("함초롬바탕", Font.BOLD | Font.ITALIC, 15));
        lblNewLabel_2.setBounds(1385109118);
        add(lblNewLabel_2);
        // ===========================================================================        
 
        // 로그인 버튼 ================================================================
        btlogin = new JButton("");
        URL url1 = getClass().getResource("imge/login.png");
        btlogin.setBounds(12560010033);
        btlogin.setIcon(new ImageIcon(url1));
        btlogin.setBorderPainted(false);
        btlogin.setFocusPainted(false);
        btlogin.setBackground(new Color(255000));
        add(btlogin);
        // ===========================================================================
 
        // 회원가입 버튼 ==============================================================
        btsign = new JButton("");
        URL url2 = getClass().getResource("imge/signup.png");
        btsign.setBounds(28960010033);
        btsign.setIcon(new ImageIcon(url2));
        btsign.setBorderPainted(false);
        btsign.setFocusPainted(false);
        btsign.setBackground(new Color(255000));
        add(btsign);
        // ===========================================================================
    }
 
    // 배경화면을 그리기 위한 작업 =====================================================
    public void paint(Graphics g) {
          panelImage = createImage(this.getWidth(), this.getHeight());
          screenGraphic= panelImage.getGraphics();
          screenDraw(screenGraphic);
          g.drawImage(panelImage, 00null);
    }
 
    public void screenDraw(Graphics g) {
           g.drawImage(backgroundImage, 00null);
           paintComponents(g);
           this.repaint();
    }
    // ===============================================================================
}
 
cs








3. Rhythm Game : SignupPanel.java


 이제 회원가입을 눌렀을 때 나올 패널을 생성합니다.

배경화면은 로그인 창의 배경화면과 동일하게 Graphics를 이용하여 gif 형태의 움짤을 넣었습니다.


회원가입할 때 필요한 사용자의 정보는 아이디, 유저 이름, 비밀번호입니다.

이때 비밀번호는 2번 입력하게 하여 원하는 비밀번호를 제대로 입력하였는지 확인하도록 구성합니다.

또한 ButtonGroup을 이용해서 회원약관에 동의 체크를 하도록 구성합니다.



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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package clientPanel;
 
import javax.swing.JPanel;
...
 
public class SignupPanel extends JPanel{
    public JTextField tfname;
    public JPasswordField tfpw;
    public JPasswordField tfrpw;
    public JTextField tfId;
    public JTextArea textArea;
    public JRadioButton rbAgree;
    public JRadioButton rbdisAgree;
    public JButton btCreate;
    public JButton btCancel;
    private Graphics screenGraphic;
    private Image panelImage;
    private Image selectedImage ;
    private Image backgroundImage = new ImageIcon(getClass().getResource("imge/123.gif")).getImage();
 
    public SignupPanel() {
        setSize(450700);
        setLayout(null);
        
        // ID 입력 ==================================================================
        JLabel lblNewLabel = new JLabel("\uD68C  \uC6D0  \uAC00  \uC785");
        lblNewLabel.setForeground(Color.WHITE);
        lblNewLabel.setFont(new Font("함초롬바탕", Font.BOLD | Font.ITALIC, 30));
        lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
        lblNewLabel.setBounds(1096322658);
        add(lblNewLabel);
        tfId = new JTextField();
        tfId.setBounds(21916311624);
        add(tfId);
        tfId.setColumns(10);
        // =============================================================================
        
        // Usert name 입력 필드
        tfname = new JTextField();
        tfname.setBounds(21919711624);
        add(tfname);
        tfname.setColumns(10);
        // =============================================================================
        
        // 비밀번호입력창 2개 =========================================================== 
        tfpw = new JPasswordField();
        tfpw.setBounds(21923111624);
        add(tfpw);
        
        tfrpw = new JPasswordField();
        tfrpw.setBounds(21926511624);
        add(tfrpw);
        // =============================================================================
        
        // 회원가입 완료 버튼=============================================================
        btCreate = new JButton("\uC644\uB8CC");
        btCreate.setBounds(8760010527);
        add(btCreate);
        // =============================================================================
        
        // 회원가입 취소 버튼=============================================================
        btCancel = new JButton("\uCDE8\uC18C");
        btCancel.setBounds(24960010527);
        add(btCancel);
        // =============================================================================
        
        // 회원약관 =====================================================================
        JScrollPane scrollPane = new JScrollPane();
        scrollPane.setBounds(48365342115);
        add(scrollPane);
        textArea = new JTextArea();
        textArea.setLineWrap(true);
        textArea.setEditable(false);
        scrollPane.setViewportView(textArea);
        textArea.setText("\uC11C\uBE44\uC2A4 \uC774\uC6A9\uC57D\uAD00\r\n\r\n\uC81C1\uC870 (\uC774\uC6A9\uACC4\uC57D\uC758 \uC131\uB9BD)\r\n\uC774\uC6A9\uACC4\uC57D\uC740 \uC774\uC6A9\uC790\uC758 \uC57D\uAD00\uB0B4\uC6A9\uC5D0 \uB300\uD55C \uB3D9\uC758\uC640 \uC774\uC6A9\uC790\uC758 \uC774\uC6A9\uC2E0\uCCAD\uC5D0 \uB300\uD55C  \uC2B9\uB099\uC73C\uB85C \uC131\uB9BD\uD569\uB2C8\uB2E4.\r\n\r\n\uC81C2\uC870 (\uC774\uC6A9\uC2E0\uCCAD)\r\n\uC774\uC6A9\uC2E0\uCCAD\uC740 \uC11C\uBE44\uC2A4\uC758 \uD68C\uC6D0\uC815\uBCF4 \uD654\uBA74\uC5D0\uC11C \uC774\uC6A9\uC790\uAC00  \uC694\uAD6C\uD558\uB294 \uAC00\uC785\uC2E0\uCCAD \uC591\uC2DD\uC5D0 \uAC1C\uC778\uC758 \uC2E0\uC0C1\uC815\uBCF4\uB97C \uAE30\uB85D\uD558\uB294 \uBC29\uC2DD\uC73C\uB85C \uC2E0\uCCAD\uD569\uB2C8\uB2E4.\r\n");
        // =============================================================================
        
        // 회원약관 동의 or 비동의 버튼 ==================================================
        ButtonGroup bg = new ButtonGroup();
        rbAgree = new JRadioButton("\uB3D9\uC758");
        rbAgree.setOpaque(false);
        rbAgree.setForeground(Color.WHITE);
        rbAgree.setBounds(1385447127);
        add(rbAgree);
        
        rbdisAgree = new JRadioButton("\uBE44\uB3D9\uC758");
        rbdisAgree.setOpaque(false);
        rbdisAgree.setForeground(Color.WHITE);
        rbdisAgree.setBounds(23054413927);
        add(rbdisAgree);
        
        bg.add(rbAgree);
        bg.add(rbdisAgree);
        // =============================================================================    
        
        // 기타 라벨 ====================================================================
        JLabel rrag = new JLabel("\uC544\uC774\uB514 : ");
        rrag.setForeground(Color.WHITE);
        rrag.setHorizontalAlignment(SwingConstants.RIGHT);
        rrag.setFont(new Font("함초롬바탕", Font.BOLD | Font.ITALIC, 15));
        rrag.setBounds(1261656218);
        add(rrag);
        
        JLabel label = new JLabel("\uC774\uB984 : ");
        label.setForeground(Color.WHITE);
        label.setHorizontalAlignment(SwingConstants.RIGHT);
        label.setFont(new Font("함초롬바탕", Font.BOLD | Font.ITALIC, 15));
        label.setBounds(1261996218);
        add(label);
        
        JLabel label_1 = new JLabel("\uBE44\uBC00\uBC88\uD638 : ");
        label_1.setForeground(Color.WHITE);
        label_1.setHorizontalAlignment(SwingConstants.RIGHT);
        label_1.setFont(new Font("함초롬바탕", Font.BOLD | Font.ITALIC, 15));
        label_1.setBounds(8323310518);
        add(label_1);
        
        JLabel label_2 = new JLabel("\uBE44\uBC00\uBC88\uD638 \uD655\uC778 : ");
        label_2.setForeground(Color.WHITE);
        label_2.setHorizontalAlignment(SwingConstants.RIGHT);
        label_2.setFont(new Font("함초롬바탕", Font.BOLD | Font.ITALIC, 15));
        label_2.setBounds(4826713918);
        add(label_2);
        
        JLabel label_3 = new JLabel("[ \uD68C\uC6D0\uC57D\uAD00 ]");
        label_3.setForeground(Color.WHITE);
        label_3.setHorizontalAlignment(SwingConstants.CENTER);
        label_3.setFont(new Font("Dialog", Font.BOLD | Font.ITALIC, 17));
        label_3.setBounds(12931117144);
        add(label_3);
        
        JLabel lblNewLabel_1 = new JLabel("\u203B \uC57D\uAD00\uC744 \uC77D\uACE0 \uB3D9\uC758 \uBC84\uD2BC\uC744 \uB20C\uB7EC\uC8FC\uC138\uC694.");
        lblNewLabel_1.setForeground(Color.RED);
        lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
        lblNewLabel_1.setBounds(4850634215);
        add(lblNewLabel_1);
        // =============================================================================
    }
    
    // 배경화면을 위한 페인트 =======================================================
    public void paint(Graphics g) {
          panelImage = createImage(this.getWidth(), this.getHeight());
          screenGraphic= panelImage.getGraphics();
          screenDraw(screenGraphic);
          g.drawImage(panelImage, 00null);
    }
    public void screenDraw(Graphics g) {
           g.drawImage(backgroundImage, 00null);
           paintComponents(g);
           this.repaint();
    // =============================================================================
    }
}
 
cs





4. Rhythm Game : BtSingnUpHandler.java


 먼저 회원가입을 위한 기능부터 구현하도록 하겠습니다. 위에서 만든 회원가입 패널로 이동할 수 있도록 리스너를 만들어주어야합니다.

리스너는 handler 패키지에 모아서 관리하도록 하겠습니다.


회원가입 패널로 이동하는 작업은 뒤에 ClientUI에서 회원가입 패널 객체를 생성해야 가능합니다. 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package handler;
 
import java.awt.Rectangle;
...
 
public class BtSingnUpHandler implements ActionListener{
    ClientUI ui;
    
    public BtSingnUpHandler(ClientUI c) {
        ui = c;
    }
 
    @Override
    public void actionPerformed(ActionEvent e) {
        // 회원가입 패널로이동 ======================
        ui.setTitle("Drop the beat!! - Signup");
        ui.setLocationRelativeTo(null);
        ui.setSize(450700);
        ui.setContentPane(ui.pnSignup);
        // ======================================
    }
}
 
cs





5. Rhythm Game : BtSingnupFinishHandler.java


이제 다음으로 회원가입을 완료 버튼을 눌렀을 때 동작할 리스너 클래스를 설계하겠습니다.


지금부터는 네트워크를 통해 서버와 데이터 통신하는 작업을 거치게 됩니다. 

핸들러에서 버튼을 클릭할 시 ClientUI에 선언되어있는 ClientNetwork 객체의 기능을 이용해 서버와 통신하는 방식입니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package handler;
 
import java.awt.event.ActionEvent;
...
 
public class BtSignupFinishHandler implements ActionListener {
    ClientUI ui;
    public BtSignupFinishHandler(ClientUI c) {
        ui = c;
    }
    @Override
    public void actionPerformed(ActionEvent e) {
        // 사용자의 입력 정보를 가져와 서버로 전송 =========================
        String nick = ui.pnSignup.tfId.getText().trim();
        String name = ui.pnSignup.tfname.getText().trim();
        String pass = String.valueOf(ui.pnSignup.tfpw.getPassword());
        String repass = String.valueOf(ui.pnSignup.tfrpw.getPassword());
        ui.net.sendCreateRequest(nick, pass, name, repass);
        // ==============================================================
    }
    
}
 
cs





6. Rhythm Game : ClientNetwork.java


 이제 본격적으로 클라이언트에서 서버로 데이터를 전송하기 위한 기능을 정의합니다.


먼저 사용자의 입력에 대한 변수를 생각하여 처리해줍니다.

서버로 데이터를 전송하기 전에 아이디 / 비밀번호의 입력 유무, 2개의 비밀번호 입력창의 일치 여부, 약관의 동의 여부를 따집니다.

후에 TCP를 이용해서 서버로 데이터를 전송합니다. 서버에서 해당 동작에 대한 작업을 진행하기 위해 필요한 인자를 '#'을 통해 구분할 수 있도록 문자열로 보내줍니다.


서버로부터 넘어온 데이터도 '#'으로 구분되어 오기 설계할 것이기 때문에 서버로부터 날라온 결과에 따른 동작을 처리하도록 설계합니다. 


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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package client;
 
import java.io.IOException;
...
 
public class ClientNetwork extends Thread {
 
    ...
 
    @Override
    public void run() {
 
        ...
 
    // 회원가입을 위한 요청 작업 ==================================================================
    public void sendCreateRequest(String nick, String pass, String name, String repass) {
        String resp = null;
        System.out.println(" [client] request : ");
        if (nick.trim().equals(""|| pass.trim().equals("")) {
            JOptionPane.showMessageDialog(ui, "아이디와 비밀번호를 입력하세요.");
            return;
        }
        if (!pass.equals(repass)) {
            JOptionPane.showMessageDialog(ui, "비밀번호를 확인하세요");
            return;
        }
        if (!ui.pnSignup.rbAgree.isSelected()) {
            JOptionPane.showMessageDialog(ui, "약관을 읽고 동의해주세요.");
            return;
        }
        synchronized (oos) {
            try {
                oos.writeObject("create#" + nick + "#" + pass + "#" + name);
 
                resp = (String) ois.readObject();
                System.out.println("[client] response : " + resp);
                String[] data = resp.split("#");
 
                // 여기서 ui 제어.
                if (data[0].equals("true")) {
                    ui.pnSignup.tfId.setText(nick);
                    ui.pnSignup.tfpw.setText("");
                    ui.pnSignup.tfname.setText("");
                    ui.pnSignup.tfrpw.setText("");
                    JOptionPane.showMessageDialog(ui, "아이디가 생성되었습니다.");
                    // 로그인 페이지로 이동.
                    ui.setSize(496748);
                    ui.setTitle("Drop the beat!! - Login");
                    ui.setContentPane(ui.pnLogin);
                    ui.pnLogin.tfid.setText(nick);
 
                } else {
                    JOptionPane.showMessageDialog(ui, data[1]);
                }
 
            } catch (ClassNotFoundException | IOException e) {
                System.out.println("[client] network error " + e.toString());
            }
        }
    }
    // =========================================================================================    
}
cs






7. Rhythm Game : PersonalServer.java 


 클라이언트에서 요청하는 값은 무조건 '#'구분을 통해 넘길 것이기 때문에 구분되는 첫 번째 요소를 처리할 작업으로 설계하겠습니다.


넘어온 아이디, 비밀번호 2개를 이용해 UserAccountPool에서 회원가입이 이루어지도록 합니다.

또한 다시 클라이언트로 전송하는 부분은 다른 기능을 사용할 때에도 공통적으로 많이 사용되기 때문에 하단에 하나의 메소드로 정의했습니다.

 

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
43
package server;
 
import java.io.IOException;
...
 
public class PersonalServer extends Thread {
    
    ...
 
    @Override
    public void run() {
        String[] command = null;
        while(socket.isConnected()) {
            String received;
            try {
                received = (String)ois.readObject();
            }catch(IOException | ClassNotFoundException e) {    // 비정상 종료시
            }
            
            System.out.println("[server] received : " + received);
            command = received.split("#");
            Object resp = null;
            System.out.println(command[0]);
            switch(command[0]) {    
                case "create":            // 회원가입
                    resp = accountPool.create(command[1], command[2], command[3]);
                    sendToClient(resp);
                    break;    
            }
        }
    }
 
    private void sendToClient(Object resp) {
        try {
            oos.reset();    
            oos.writeObject(resp);
            System.out.println(resp);
        }catch(IOException e) {
            System.out.println("server write fail.. " + e.toString());
        }
    }    
}
 
cs






8. Rhythm Game : UserAccountPool.java 


  회원가입을 할 수 없는 경우는 이미 아이디가 존재할 경우밖에 없기 때문에 간단합니다.


유저의 전체 계정을 보관하는 accountMap 변수에서 해당 id가 존재하는지 확인한 후에 이미 존재하면 false를 존재하지 않는다면 새로운 Account 객체를 생성하여 accountMap에 저장한 후 true를 반환합니다.


이렇게 설계가 되었다면 서버에서 클라이언트에 요청에 대한 결과를 resp 변수에 담아 다시 클라이언트로 전송하고, 클라이언트는 다시 전송된 데이터의 값에 따라 회원가입의 성공 유무를 따져 동작할 것을 결정하게 됩니다.

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
public class UserAccountPool {
    private Map<String,Account> accountMap;        // 유저의 계정 보관
    private Set<Account> currentUser;            // 현재 접속중인 유저
    private File address;                        
    
    // 생성자 ==========================================================
    public UserAccountPool() {

        accountMap = new HashMap<>();
        currentUser = new HashSet<>();
    }
    // ================================================================
    
 
    // 회원가입을 위한 메소드
    public String create(String id, String pass, String name) {            
        if(accountMap.containsKey(id)) {
            return "false#이미 아이디가 존재합니다.";
        } else {
            accountMap.put(id, new Account(id, pass, name));
            System.out.println(accountMap);
            return "true";
        }
    }
    
    ...
 
}
 
cs





9. Rhythm Game : BtSignUpCancelHandler.java 


 이제 회원가입 패널에서 회원가입을 하지않고 취소 버튼을 눌렀을 시에 작동할 리스너 클래스를 만들어 줍니다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package handler;
 
import java.awt.event.ActionEvent;
...
 
public class BtSignUpCancelHandler implements ActionListener {
    ClientUI ui;
    public BtSignUpCancelHandler(ClientUI c) {
        ui = c;
    }
    @Override
    public void actionPerformed(ActionEvent e) {
        // 로그인 패널로 이동 =====================
        ui.setTitle("Drop the beat!! - Login");
        ui.setSize(496748);
        ui.setContentPane(ui.pnLogin);
        // =======================================
    }
}
 
cs






10. Rhythm Game : ClientUI.java 


위의 회원가입 흐름을 이해하고 계신다면 중간에 연결고리 하나가 빠졌다는 것을 아실 수 있을 것입니다. 

바로 버튼을 클릭했을 때 리스너를 호출하기 위한 작업과 회원가입 패널로 이동하기 위해 회원가입 패널 객체를 생성하는 것입니다.



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
package client;
 
import java.awt.event.ActionListener;
...
 
public class ClientUI extends JFrame{
 
    public SignupPanel pnSignup;
 
    ...
     private void addListeners() {
        // 회원가입 패널로 이동하기 위한 리스너 호출 =============
        ActionListener bsh = new BtSingnUpHandler(this);
        pnLogin.btsign.addActionListener(bsh);
        // ====================================================
 
        // 회원가입 완료되었을 때 리스너 호출 ====================
        ActionListener bsfh = new BtSignupFinishHandler(this);
        pnSignup.btCreate.addActionListener(bsfh);
        // ====================================================
 
        // 회원가입 패널에서 취소 버튼 클릭시 리스너 호출 =========
        ActionListener bch = new BtSignUpCancelHandler(this);
        pnSignup.btCancel.addActionListener(bch);
        // ====================================================
    }
    private void setUIcomponent() {
        
        ...
 
        setTitle("Drop the beat!! - Login");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setResizable(false);
        setSize(496748);
        pnSignup = new SignupPanel();        // 회원가입 패널 객체 생성
        pnLogin = new LoginPanel();
        setContentPane(pnLogin);
    }
}
cs




## 회원가입 기능에 대한 클래스 동작 흐름.

로그인 패널에서 회원가입 버튼 클릭 -> 리스너 호출(BtSignUpHandler.java) -> 회원가입 패널 이동 

 -> 회원가입 완료 버튼 클릭 시 -> BtSignUpFinishHandler.java 리스너 호출 -> ClientNetwork에서 서버로 데이터 전송 

(Server) 전송 받은 데이터에 대한 처리 -> 클라이언트에게 처리에 대한 결과 전송 ->

(Client) 서버로부터 받은 결과로 로그인 패널로 이동하거나 실패 다이얼로그 출력

 -> 취소 버튼 클릭시 -> BtSignUpCancelHandler.java 리스너 호출 -> 로그인 패널로 이동




공지사항
최근에 올라온 글
최근에 달린 댓글
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
글 보관함