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 | package com.jse.member; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; public class MemberSwing { public static void main(String[] args) { JoinFrame jf = new JoinFrame(); jf.execute(); } } class JoinFrame extends JFrame implements ActionListener{ private static final long serialVersionUID = 1L; JFrame frame = new JFrame("Member Sign-up"); JLabel useridLabel = new JLabel("User ID : ", JLabel.RIGHT); JLabel passwordLabel = new JLabel("Password : ", JLabel.RIGHT); JLabel nameLabel = new JLabel("Name : ", JLabel.RIGHT); JLabel ssnLabel = new JLabel("SSN : ", JLabel.RIGHT); JTextField useridField = new JTextField(10); JTextField passwordField = new JTextField(10); JTextField nameField = new JTextField(10); JTextField ssnField = new JTextField(10); JButton joinButton = new JButton("Join"); JButton cancelButton = new JButton("Cancel"); public void execute() { frame.setLayout(new GridLayout(8, 2)); JPanel useridPanel = new JPanel(); useridPanel.add(useridLabel); useridPanel.add(useridField); JPanel passwordPanel = new JPanel(); passwordPanel.add(passwordLabel); passwordPanel.add(passwordField); JPanel namePanel = new JPanel(); namePanel.add(nameLabel); namePanel.add(nameField); JPanel ssnPanel = new JPanel(); ssnPanel.add(ssnLabel); ssnPanel.add(ssnField); JPanel buttonPanel = new JPanel(); buttonPanel.add(joinButton); buttonPanel.add(cancelButton); joinButton.addActionListener(this); cancelButton.addActionListener(this); frame.add(useridPanel); frame.add(passwordPanel); frame.add(namePanel); frame.add(ssnPanel); frame.add(buttonPanel); frame.setSize(300, 300); frame.setResizable(false); frame.setLocationRelativeTo(null); frame.setVisible(true); } @Override public void actionPerformed(ActionEvent e) { if(e.getSource() == joinButton) { JOptionPane.showMessageDialog(this, useridField.getText()); } } } | cs |
'Java' 카테고리의 다른 글
[자바 Swing] 로또 LottoMain.java LottoUI.java Lotto.java (0) | 2020.04.30 |
---|---|
[자바 객체지향] 인터페이스 활용한 가위바위보 게임 Rps.java (0) | 2020.04.30 |
[자바 객체지향] 인터페이스 예제 Bank.java (0) | 2020.04.30 |
[자바 알고리즘] 행렬을 이용한 풀이 Lotto.java (0) | 2020.04.30 |
40. 회원관리 Swing 앱 :: MemberView.java (0) | 2020.04.14 |