Salted Caramel

[수업 20일차] 21.09.01 GUI (화면구현4) 이벤트 예제, 로그인 화면 본문

coding/[2021.08.02~2022.01.24] 수업복습

[수업 20일차] 21.09.01 GUI (화면구현4) 이벤트 예제, 로그인 화면

꽃무늬라떼 2021. 9. 2. 02:12
package sist;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.nio.ByteOrder;

import javax.swing.*;

public class Ex39_Event extends JFrame {

	public Ex39_Event() {
		
		setTitle("성적 처리");
		
		JPanel container1 = new JPanel();     // 상단-1 컨테이너
		JPanel container2 = new JPanel();     // 상단-2 컨테이너
		JPanel container3 = new JPanel();     // 하단 컨테이너
		
		// 1. 컴포넌트를 만들어 보자.
		// 1-1. 상단-1 컨테이너에 들어갈 컴포넌트를 만들자.
		JLabel label1 = new JLabel("이 름 : ");
		JTextField jtf1 = new JTextField(10);
		
		// 1-2. 상단-2 컨테이너에 들어갈 컴포넌트를 만들자.
		JLabel label2 = new JLabel("국 어 : ");
		JTextField jtf2 = new JTextField(3);
		
		JLabel label3 = new JLabel("영 어 : ");
		JTextField jtf3 = new JTextField(3);
		
		JLabel label4 = new JLabel("수 학 : ");
		JTextField jtf4 = new JTextField(3);
		
		// 1-3. 중앙에 들어갈 컴포넌트를 만들자.
		JTextArea jta = new JTextArea(5, 20);
		JScrollPane jsp = new JScrollPane(
				jta, 
				ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, 
				ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
		
		jta.setLineWrap(true);
		
		// 1-4. 하단 컨테이너에 들어갈 컴포넌트를 만들자.
		JButton result = new JButton("계  산");
		JButton exit = new JButton("종  료");
		JButton cancel = new JButton("취  소");
		
		// 2. 컨테이너에 컴포넌트를 올려야 한다.
		// 2-1. 상단-1 컨테이너에 1-1 컴포넌트를 올리자.
		container1.add(label1); container1.add(jtf1);
		
		// 2-2. 상단-2 컨테이너에 1-2 컴포넌트를 올리자.
		container2.add(label2); container2.add(jtf2);
		container2.add(label3); container2.add(jtf3);
		container2.add(label4); container2.add(jtf4);
		
		// 2-3. 하단 컨테이너에 1-4 컴포넌트를 올리자.
		container3.add(result);
		container3.add(exit); container3.add(cancel);
		
		
		// 새로운 컨테이너 하나를 만들어서 기존의 컨테이너들을 올리자.
		JPanel group = new JPanel(new BorderLayout());
		
		group.add(container2, BorderLayout.NORTH);
		group.add(jsp, BorderLayout.CENTER);
		group.add(container3, BorderLayout.SOUTH);
		
		// 3. 프레임에 컨테이너를 올려야 한다.
		add(container1, BorderLayout.NORTH);
		add(group, BorderLayout.CENTER);
		
		setBounds(200, 200, 300, 300);
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		setVisible(true);
		
		
		// 4. 이벤트 처리
		// 계산(result) 버튼을 클릭했을 때 이벤트 처리
		result.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				String name = jtf1.getText();
				int kor = Integer.parseInt(jtf2.getText());
				int eng = Integer.parseInt(jtf3.getText());
				int mat = Integer.parseInt(jtf4.getText());
				
				// 총점 구하기
				int sum = kor + eng + mat;
				
				// 평균 구하기
				double avg = sum / 3.0;
				
				// 학점 구하기
				String grade = null;
				
				if(avg >= 90) {
					grade = "A학점";
				}else if(avg >= 80) {
					grade = "B학점";
				}else if(avg >= 70) {
					grade = "C학점";
				}else if(avg >= 60) {
					grade = "D학점";
				}else {
					grade = "F학점";
				}
				
				
				// JTextArea 영역에 성적 결과를 출력하자.
				jta.append("*** "+name+"님 성적 결과 ***\n");
				jta.append("이      름 : " + name + "\n");
				jta.append("국어점수 : " + kor +"점\n");
				jta.append("영어점수 : " + eng +"점\n");
				jta.append("수학점수 : " + mat +"점\n");
				jta.append("총      점 : " + sum +"점\n");
				jta.append("평      균 : " + String.format("%.2f점", avg) +"\n");
				jta.append("학      점 : " + grade +"\n");
				
				// 각각의 컴포넌트 영역 초기화 작업
				jtf1.setText(""); jtf2.setText("");
				jtf3.setText(null); jtf4.setText(null);
				
				jtf1.requestFocus();
				
			}
		});
		
		// 종료(exit) 버튼 클릭 시 이벤트 처리
		exit.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
				
			}
		});
		
		// 취소(cancel) 버튼 클릭 시 이벤트 처리
		cancel.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				
				// 각각의 컴포넌트 영역 초기화 작업
				jtf1.setText(""); jtf2.setText("");
				jtf3.setText(null); jtf4.setText(null);
				jta.setText(null);
				
				jtf1.requestFocus();
				
			}
		});
	}
	
	public static void main(String[] args) {
		
		new Ex39_Event();
	}

}

package sist;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class Ex40_Event extends JFrame {

	public Ex40_Event() {
		
		setTitle("커피 자판기");
		
		JPanel container1 = new JPanel();    // 상단-1 컨테이너
		JPanel container2 = new JPanel();    // 상단-2 컨테이너
		JPanel container3 = new JPanel();    // 상단-3 컨테이너
		JPanel container4 = new JPanel();    // 하단 컨테이너
		
		// 1. 컴포넌트를 만들어 보자.
		// 1-1. 상단-1 컨테이너에 올려질 컴포넌트를 만들자.
		JLabel label1 = new JLabel("원하는 커피 선택");
		
		// 1-2. 상단-2 컨테이너에 올려질 컴포넌트를 만들자.
		JRadioButton jrb1 = new JRadioButton("아메리카노(2500)");
		JRadioButton jrb2 = new JRadioButton("카페모카(3500)");
		JRadioButton jrb3 = new JRadioButton("에스프레소(2500)");
		JRadioButton jrb4 = new JRadioButton("카페라떼(4000)");
		
		ButtonGroup bg = new ButtonGroup();
		bg.add(jrb1); bg.add(jrb2);
		bg.add(jrb3); bg.add(jrb4);
		
		// 1-3. 상단-3 컨테이너에 올려질 컴포넌트를 만들자.
		JLabel label2 = new JLabel("수  량 : ");
		JTextField jtf1 = new JTextField(5);
		
		JLabel label3 = new JLabel("입금액 : ");
		JTextField jtf2 = new JTextField(10);
		
		// 1-4. 중앙에 들어갈 컴포넌트를 만들자.
		JTextArea jta = new JTextArea(5, 20);
		JScrollPane jsp = new JScrollPane(
				jta, 
				ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, 
				ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
		
		jta.setLineWrap(true);
		
		// 1-5. 하단 컨테이너에 들어갈 컴포넌트를 만들자.
		JButton result = new JButton("계  산");
		JButton exit = new JButton("종  료");
		JButton cancel = new JButton("취  소");
		
		// 2. 컨테이너에 컴포넌트를 올려야 한다.
		// 2-1. 상단-1 컨테이너에 1-1 컴포넌트를 올리자.
		container1.add(label1);
		
		// 2-2. 상단-2 컨테이너에 1-2 컴포넌트를 올리자.
		container2.add(jrb1); container2.add(jrb2);
		container2.add(jrb3); container2.add(jrb4);
		
		// 2-3. 상단-3 컨테이너에 1-3 컴포넌트를 올리자.
		container3.add(label2); container3.add(jtf1);
		container3.add(label3); container3.add(jtf2);
		
		// 2-4. 하단 컨테이너에 1-4 컴포넌트를 올리자.
		container4.add(result);
		container4.add(exit); container4.add(cancel);
		
		// 새로운 컨테이너 두개를 새로 만들자.
		JPanel group1 = new JPanel(new BorderLayout());
		JPanel group2 = new JPanel(new BorderLayout());
		
		// group1 컨테이너에는 기존의 container1, container2 컨테이너를 올리자.
		group1.add(container1, BorderLayout.NORTH);
		group1.add(container2, BorderLayout.CENTER);
		
		// group2 컨테이너에는 기존의 container3, jsp, container4 컨테이너를 올리자.
		group2.add(container3, BorderLayout.NORTH);
		group2.add(jsp, BorderLayout.CENTER);
		group2.add(container4, BorderLayout.SOUTH);
		
		// 3. 프레임에 컨테이너를 올려야 한다.
		add(group1, BorderLayout.NORTH);
		add(group2, BorderLayout.CENTER);
		
		setBounds(200, 200, 300, 300);
		
		pack();
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		setVisible(true);
		
		
		// 4. 이벤트 처리
		// 계산(result) 버튼 클릭 시 이벤트 처리
		result.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				
				String coffeeStr = null;   // 커피 종류 변수
				int coffeeInt = 0;         // 커피 단가 변수
				
				if(jrb1.isSelected()) {
					coffeeStr = "아메리카노";
					coffeeInt = 2500;
				}else if(jrb2.isSelected()) {
					coffeeStr = "카페모카";
					coffeeInt = 3500;
				}else if(jrb3.isSelected()) {
					coffeeStr = "에스프레소";
					coffeeInt = 2500;
				}else if(jrb4.isSelected()) {
					coffeeStr = "카페라떼";
					coffeeInt = 4000;
				}
				
				int amount = Integer.parseInt(jtf1.getText());
				
				int money = Integer.parseInt(jtf2.getText());
				
				// 공급가액 : 수량(amount) * 단가(coffeeInt)
				int sum = amount * coffeeInt;
				
				// 부가세액 : 공급가액 * 0.1
				int vat = (int)(sum * 0.1);
				
				// 총금액 : 공급가액 + 부가세액
				int total = sum + vat;
				
				// 잔액 계산 : 입금액(money) - 총금액
				int result = money - total;
				
				// JTextArea 컴포넌트에 내용을 출력해 보자.
				jta.append("커피종류 : " + coffeeStr + "\n");
				jta.append("커피단가 : " + coffeeInt + "원\n");
				jta.append("수      량 : " + amount + "\n");
				jta.append("공급가액 : " + String.format("%,d원", sum) + "\n");
				jta.append("부가세액 : " + String.format("%,d원", vat) + "\n");
				jta.append("총 금 액 : " + String.format("%,d원", total) + "\n");
				jta.append("입 금 액 : " + String.format("%,d원", money) + "\n");
				jta.append("거스름돈 : " + String.format("%,d원", result) + "\n");
				
				// 각각의 컴포넌트 영역 초기화
				bg.clearSelection();
				jtf1.setText(null); jtf2.setText(null);
			}
		});
		
		// 종료(exit) 버튼 클릭 시 이벤트 처리
		exit.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				
				System.exit(0);
				
			}
		});
		
		// 취소(cancel) 버튼 클릭 시 이벤트 처리
		cancel.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				
				// 각각의 컴포넌트 영역 초기화
				bg.clearSelection();
				jtf1.setText(null); jtf2.setText(null);
				jta.setText(null);
			}
		});
	}
	
	
	public static void main(String[] args) {
		
		new Ex40_Event();

	}

}

package sist;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class Ex40_Event extends JFrame {

	public Ex40_Event() {
		
		setTitle("커피 자판기");
		
		JPanel container1 = new JPanel();    // 상단-1 컨테이너
		JPanel container2 = new JPanel();    // 상단-2 컨테이너
		JPanel container3 = new JPanel();    // 상단-3 컨테이너
		JPanel container4 = new JPanel();    // 하단 컨테이너
		
		// 1. 컴포넌트를 만들어 보자.
		// 1-1. 상단-1 컨테이너에 올려질 컴포넌트를 만들자.
		JLabel label1 = new JLabel("원하는 커피 선택");
		
		// 1-2. 상단-2 컨테이너에 올려질 컴포넌트를 만들자.
		JRadioButton jrb1 = new JRadioButton("아메리카노(2500)");
		JRadioButton jrb2 = new JRadioButton("카페모카(3500)");
		JRadioButton jrb3 = new JRadioButton("에스프레소(2500)");
		JRadioButton jrb4 = new JRadioButton("카페라떼(4000)");
		
		ButtonGroup bg = new ButtonGroup();
		bg.add(jrb1); bg.add(jrb2);
		bg.add(jrb3); bg.add(jrb4);
		
		// 1-3. 상단-3 컨테이너에 올려질 컴포넌트를 만들자.
		JLabel label2 = new JLabel("수  량 : ");
		JTextField jtf1 = new JTextField(5);
		
		JLabel label3 = new JLabel("입금액 : ");
		JTextField jtf2 = new JTextField(10);
		
		// 1-4. 중앙에 들어갈 컴포넌트를 만들자.
		JTextArea jta = new JTextArea(5, 20);
		JScrollPane jsp = new JScrollPane(
				jta, 
				ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, 
				ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
		
		jta.setLineWrap(true);
		
		// 1-5. 하단 컨테이너에 들어갈 컴포넌트를 만들자.
		JButton result = new JButton("계  산");
		JButton exit = new JButton("종  료");
		JButton cancel = new JButton("취  소");
		
		// 2. 컨테이너에 컴포넌트를 올려야 한다.
		// 2-1. 상단-1 컨테이너에 1-1 컴포넌트를 올리자.
		container1.add(label1);
		
		// 2-2. 상단-2 컨테이너에 1-2 컴포넌트를 올리자.
		container2.add(jrb1); container2.add(jrb2);
		container2.add(jrb3); container2.add(jrb4);
		
		// 2-3. 상단-3 컨테이너에 1-3 컴포넌트를 올리자.
		container3.add(label2); container3.add(jtf1);
		container3.add(label3); container3.add(jtf2);
		
		// 2-4. 하단 컨테이너에 1-4 컴포넌트를 올리자.
		container4.add(result);
		container4.add(exit); container4.add(cancel);
		
		// 새로운 컨테이너 두개를 새로 만들자.
		JPanel group1 = new JPanel(new BorderLayout());
		JPanel group2 = new JPanel(new BorderLayout());
		
		// group1 컨테이너에는 기존의 container1, container2 컨테이너를 올리자.
		group1.add(container1, BorderLayout.NORTH);
		group1.add(container2, BorderLayout.CENTER);
		
		// group2 컨테이너에는 기존의 container3, jsp, container4 컨테이너를 올리자.
		group2.add(container3, BorderLayout.NORTH);
		group2.add(jsp, BorderLayout.CENTER);
		group2.add(container4, BorderLayout.SOUTH);
		
		// 3. 프레임에 컨테이너를 올려야 한다.
		add(group1, BorderLayout.NORTH);
		add(group2, BorderLayout.CENTER);
		
		setBounds(200, 200, 300, 300);
		
		pack();
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		setVisible(true);
		
		
		// 4. 이벤트 처리
		// 계산(result) 버튼 클릭 시 이벤트 처리
		result.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				
				String coffeeStr = null;   // 커피 종류 변수
				int coffeeInt = 0;         // 커피 단가 변수
				
				if(jrb1.isSelected()) {
					coffeeStr = "아메리카노";
					coffeeInt = 2500;
				}else if(jrb2.isSelected()) {
					coffeeStr = "카페모카";
					coffeeInt = 3500;
				}else if(jrb3.isSelected()) {
					coffeeStr = "에스프레소";
					coffeeInt = 2500;
				}else if(jrb4.isSelected()) {
					coffeeStr = "카페라떼";
					coffeeInt = 4000;
				}
				
				int amount = Integer.parseInt(jtf1.getText());
				
				int money = Integer.parseInt(jtf2.getText());
				
				// 공급가액 : 수량(amount) * 단가(coffeeInt)
				int sum = amount * coffeeInt;
				
				// 부가세액 : 공급가액 * 0.1
				int vat = (int)(sum * 0.1);
				
				// 총금액 : 공급가액 + 부가세액
				int total = sum + vat;
				
				// 잔액 계산 : 입금액(money) - 총금액
				int result = money - total;
				
				// JTextArea 컴포넌트에 내용을 출력해 보자.
				jta.append("커피종류 : " + coffeeStr + "\n");
				jta.append("커피단가 : " + coffeeInt + "원\n");
				jta.append("수      량 : " + amount + "\n");
				jta.append("공급가액 : " + String.format("%,d원", sum) + "\n");
				jta.append("부가세액 : " + String.format("%,d원", vat) + "\n");
				jta.append("총 금 액 : " + String.format("%,d원", total) + "\n");
				jta.append("입 금 액 : " + String.format("%,d원", money) + "\n");
				jta.append("거스름돈 : " + String.format("%,d원", result) + "\n");
				
				// 각각의 컴포넌트 영역 초기화
				bg.clearSelection();
				jtf1.setText(null); jtf2.setText(null);
			}
		});
		
		// 종료(exit) 버튼 클릭 시 이벤트 처리
		exit.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				
				System.exit(0);
				
			}
		});
		
		// 취소(cancel) 버튼 클릭 시 이벤트 처리
		cancel.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				
				// 각각의 컴포넌트 영역 초기화
				bg.clearSelection();
				jtf1.setText(null); jtf2.setText(null);
				jta.setText(null);
			}
		});
	}
	
	
	public static void main(String[] args) {
		
		new Ex40_Event();

	}

}
package exam;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Rectangle2D.Float;

import javax.swing.*;

public class LoginScreen extends JFrame {

	public LoginScreen() {
		
		setTitle("로그인 페이지");
		
		JPanel title = new JPanel();
		
		// title 컨테이너에 올려질 컴포넌트를 만들어 보자.
		JLabel login = new JLabel("로그인 화면");
		
		login.setForeground(new Color(5, 0, 153));
		
		login.setFont(new Font("휴먼편지체", Font.BOLD, 25));
		
		// title 컨테이너에 컴포넌트(login)를 올리자.
		title.add(login);
		
		JPanel container1 = new JPanel(new GridLayout(3, 2));
		
		JPanel idPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
		JLabel label1 = new JLabel("아이디 : ", JLabel.CENTER);
		
		idPanel.add(label1);
		
		JPanel idPane2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
		JTextField jtf1 = new JTextField(10);
		
		idPane2.add(jtf1);
		
		container1.add(idPanel); container1.add(idPane2);
		
		
		JPanel pwdPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
		JLabel label2 = new JLabel("비밀번호 : ", JLabel.CENTER);
		
		JPanel pwdPanel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
		JPasswordField jtf2 = new JPasswordField(10);
		
		pwdPanel.add(label2); pwdPanel2.add(jtf2);
		
		container1.add(pwdPanel); container1.add(pwdPanel2);
		
		JPanel loginPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
		JButton jLogin = new JButton("로그인");
		
		JPanel joinPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
		JButton join = new JButton("회원가입");
		
		loginPanel.add(jLogin); joinPanel.add(join);
		
		container1.add(loginPanel); container1.add(joinPanel);
		
		JPanel container2 = new JPanel();
		container2.setLayout(new FlowLayout());
		container2.add(container1);
		
		setLayout(new BorderLayout());
		
		add(title, BorderLayout.NORTH);
		add(container2, BorderLayout.CENTER);
		
		setBounds(200, 200, 300, 250);
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		setVisible(true);
		
		
		// 이벤트 처리
		jLogin.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				String myId = jtf1.getText();
				String myPwd = new String(jtf2.getPassword());
				
				JOptionPane.showMessageDialog
					(null, "아이디 : "+myId+", 비밀번호 : " + myPwd);
			}
		});
		
		join.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				
				new JoinScreen();
				dispose();
				
			}
		});
		
	}
}
package exam;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class JoinScreen extends JFrame {
	
	public JoinScreen() {
		
		setTitle("회원가입 화면");
		
		// 1. 컴포넌트들을 만들어 보자.
		JLabel title = new JLabel("회원가입", JLabel.CENTER);
		
		title.setForeground(new Color(5, 0, 153));
		title.setFont(new Font("휴먼편지체",Font.BOLD, 30));
		
		JButton join = new JButton("회원가입");
		JButton cancel = new JButton("취소");
		
		JTextField id = new JTextField(10);
		JPasswordField pwd = new JPasswordField(10);
		JTextField name = new JTextField(10);
		JTextField phone = new JTextField(10);
		
		JRadioButton client = new JRadioButton("고객");
		JRadioButton manager = new JRadioButton("관리자");
		JRadioButton etc = new JRadioButton("기타");
		
		ButtonGroup bg = new ButtonGroup();
		bg.add(client); bg.add(manager); bg.add(etc);
		
		
		// radio 컨테이너
		JPanel radioPanel = new JPanel();
		radioPanel.add(client); radioPanel.add(manager); radioPanel.add(etc);
		
		// form 컨테이너
		JPanel idPanel = new JPanel();
		idPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
		idPanel.add(new JLabel("아이디 : "));
		idPanel.add(id);
		
		JPanel pwdPanel = new JPanel();
		pwdPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
		pwdPanel.add(new JLabel("비밀번호 : "));
		pwdPanel.add(pwd);
		
		JPanel namePanel = new JPanel();
		namePanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
		namePanel.add(new JLabel("이     름 : "));
		namePanel.add(name);
		
		JPanel phonePanel = new JPanel();
		phonePanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
		phonePanel.add(new JLabel("연 락 처 : "));
		phonePanel.add(phone);
		
		JPanel formPanel = new JPanel();
		formPanel.setLayout(new GridLayout(4, 1));
		formPanel.add(idPanel); formPanel.add(pwdPanel);
		formPanel.add(namePanel); formPanel.add(phonePanel);
		
		// radio + form panel
		JPanel contentPanel = new JPanel();
		contentPanel.setLayout(new FlowLayout());
		contentPanel.add(radioPanel);
		contentPanel.add(formPanel);
		
		// button panel
		JPanel buttonPanel = new JPanel();
		buttonPanel.add(join); buttonPanel.add(cancel);
		
		// 프레임에 컨테이너를 올려야 한다.
		add(title, BorderLayout.NORTH);
		add(contentPanel, BorderLayout.CENTER);
		add(buttonPanel, BorderLayout.SOUTH);
		
		setBounds(200, 200, 250, 300);
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		setVisible(true);
		
	
		// 이벤트 처리
		join.addActionListener(new ActionListener() {
			
			String choice = null;
			
			@Override
			public void actionPerformed(ActionEvent e) {
				
				String myId = id.getText();
				String myPwd = new String(pwd.getPassword());
				String myName = name.getText();
				String myPhone = phone.getText();
				
				if(client.isSelected()) {
					choice = client.getText();
				}else if(manager.isSelected()) {
					choice = manager.getText();
				}else if(etc.isSelected()) {
					choice = etc.getText();
				}
				
				JOptionPane.showMessageDialog
					(null, "아이디 : "+myId+", 비밀번호 : " + myPwd+
						", 이  름 : " + myName+ ", 연락처 : " + myPhone+
						", 가입유형 : " + choice);
			}
		});
		
		// 취소 버튼을 클릭했을 때 이벤트 처리
		cancel.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				
				new Main();
				dispose();
				
			}
		});
		
	}

}

 

Database

 

https://www.oracle.com/tools/downloads/sqldev-downloads.html

 

 

 

Microsoft Windows [Version 10.0.19042.1165]
(c) Microsoft Corporation. All rights reserved.

C:\Users\amorf>sqlplus / as sysdba

SQL*Plus: Release 18.0.0.0.0 - Production on 수 9월 1 14:52:13 2021
Version 18.4.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.


다음에 접속됨:
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

SQL> create user web indetified by 1234;
create user web indetified by 1234
                *
1행에 오류:
ORA-00922: 누락된 또는 부적합한 옵션


SQL>
SQL> alter session set "_ORACLE_SCRIPT"=true;

세션이 변경되었습니다.

SQL> create user web identified by 1234;

사용자가 생성되었습니다.

SQL> grant connect, resource, dba to web;

권한이 부여되었습니다.

SQL> exit
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0에서 분리되었습니다.

C:\Users\amorf>