지구정복

[미니프로젝트] Java Swing을 이용한 CRUD프로그램 만들기(축구선수 관리 프로그램) 본문

프로젝트

[미니프로젝트] Java Swing을 이용한 CRUD프로그램 만들기(축구선수 관리 프로그램)

eeaarrtthh 2020. 12. 17. 15:38
728x90
반응형

 

 

1. 기획

-Use Case Diagram

-Sequence Diagram

 

-E-R Diagram

 

-Wire Frame

 

 

K-League_Player_UI_1215_1619.pptx
0.06MB

 

 

 

 

 

2. 코딩 구현

-클래스 

 

2.1 데이터 베이스 설계

-데이터 베이스 DDL

--데이터베이스 생성
create database uiproject;

use uiproject;

drop table user;

----유저 테이블 생성
create table user (
u_id varchar(30) primary key,
u_pass varchar(30) not null,
u_name varchar(10) not null,
u_gender varchar(5) check (u_gender in ('남', '여') ),
u_birth date,
u_pno varchar(30) not null,
constraint uni_pno unique(u_pno)
);

insert into user values('root', '!123456', '이지훈', '남', '1111-11-11', '010-1234-1234');

----팀 테이블 생성
drop table team;

create table team(
t_code varchar(30),
t_name varchar(50),
t_coach varchar(50),
t_loc varchar(50),
t_year varchar(10),
primary key(t_code)
);

select * from team;

----선수 테이블 생성
drop table player;

create table player(
p_no int(30) ,
t_code varchar(30),
p_name varchar(50),
p_length varchar(50),
p_birth varchar(10),
p_weight varchar(50),
p_pos varchar(20),
p_backno int(4),
p_goal int(4),
p_assi int(4),
primary key(p_no),
foreign key(t_code) references team(t_code)
);

select * from player order by p_no desc limit 5;
select * from player limit 50;

 

2.2 선수 및 팀 데이터 데이터베이스 안에 집어넣기

 

player.csv
0.03MB

 

 

 

team.csv
0.00MB

 

 

 

-TeamTO

package Pack_Team;

public class TeamTO {
	private String t_code;
	private String t_name;
	private String t_coach;
	private String t_loc;
	private String t_year;
	
	public TeamTO() {
	}

	public String getT_code() {
		return t_code;
	}
	public String getT_name() {
		return t_name;
	}
	public String getT_coach() {
		return t_coach;
	}
	public String getT_loc() {
		return t_loc;
	}
	public String getT_year() {
		return t_year;
	}
	
	public void setT_code(String t_code) {
		this.t_code = t_code;
	}
	public void setT_name(String t_name) {
		this.t_name = t_name;
	}
	public void setT_coach(String t_coach) {
		this.t_coach = t_coach;
	}
	public void setT_loc(String t_loc) {
		this.t_loc = t_loc;
	}
	public void setT_year(String t_year) {
		this.t_year = t_year;
	}
}

-TeamDAO

package Pack_Team;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Scanner;

public class TeamDAO {
	private Connection conn;
	private ArrayList<TeamTO> teams = new ArrayList<TeamTO>();

	public TeamDAO() {
		//db 연결정보 설정 및 드라이버 로딩
		String url = "jdbc:mysql://localhost:3307/uiproject";
		String user = "root";
		String password = "!123456";
		
		try {
			Class.forName( "org.mariadb.jdbc.Driver" );
			this.conn = DriverManager.getConnection(url, user, password);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	//팀 추가하기 메서드
	public void InsertTeam() {
		try {
			//선수엑셀파일 가져오기
			BufferedReader br = new BufferedReader( new FileReader( "./team.csv" ) );
			String team = null;
			
			//sql문 선언 및 엑셀파일읽어서 sql문 실행
			String sql = 
			"insert into team values(?, ?, ?, ?, ?)";
			PreparedStatement pstmt = this.conn.prepareStatement(sql);
			
			while( (team = br.readLine() ) != null ) {
				String[] teams = team.split(",");
				pstmt.setString( 1, teams[0] );
				pstmt.setString( 2, teams[1] );
				pstmt.setString( 3, teams[2] );
				pstmt.setString( 4, teams[3] );
				pstmt.setString( 5, teams[4] );
				
				ResultSet rs = pstmt.executeQuery();
				if ( rs != null ) rs.close();
			}
			
			if ( pstmt != null ) pstmt.close();
			if ( conn != null ) conn.close();
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	//모든 팀 리턴해주는 메소드 (선수 추가 패널의 콤보박스 만들 때 사용)
	public ArrayList<TeamTO> selectTeam() {
		String sql = "select t_code, t_name from team order by t_code asc";
		try {
			PreparedStatement pstmt = this.conn.prepareStatement(sql);
			ResultSet rs = pstmt.executeQuery();
			
			while( rs.next() ) {
				TeamTO to = new TeamTO();
				to.setT_code( rs.getString( 1 ) );
				to.setT_name( rs.getString( 2 ) );
				teams.add( to );
			}
			
			if ( rs != null ) rs.close();
			if ( pstmt != null ) pstmt.close();
			if ( conn != null ) conn.close();
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return teams;
	}
	
}

-InsertTeam (실행클래스)

package Pack_Team;

public class InsertTeam {

	public static void main(String[] args) {
		TeamDAO dao = new TeamDAO();
		
		dao.InsertTeam();
		System.out.println( "팀 저장이 완료되었습니다." );
	}
}

 

-SoccerTO

package Pack_Player;

public class SoccerTO {
	private String p_name;
	private String p_backno;
	private String t_code;
	private String p_length;
	private String p_weight;
	private String p_birth;
	private String p_no;
	private String p_pos;
	
	public SoccerTO() {
	}

	public void setP_name(String p_name) {
		this.p_name = p_name;
	}
	public void setP_backno(String p_backno) {
		this.p_backno = p_backno;
	}
	public void setT_code(String t_code) {
		this.t_code = t_code;
	}
	public void setP_length(String p_length) {
		this.p_length = p_length;
	}
	public void setP_weight(String p_weight) {
		this.p_weight = p_weight;
	}
	public void setP_birth(String p_birth) {
		this.p_birth = p_birth;
	}
	public void setP_no(String p_no) {
		this.p_no = p_no;
	}
	public void setP_pos(String p_pos) {
		this.p_pos = p_pos;
	}

	public String getP_name() {
		return p_name;
	}
	public String getP_backno() {
		return p_backno;
	}
	public String getT_code() {
		return t_code;
	}
	public String getP_length() {
		return p_length;
	}
	public String getP_weight() {
		return p_weight;
	}
	public String getP_birth() {
		return p_birth;
	}
	public String getP_no() {
		return p_no;
	}
	public String getP_pos() {
		return p_pos;
	}
}

-SoccerDAO

package Pack_Player;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

public class SoccerDAO {
	private Connection conn;
	private ArrayList<SoccerTO> players = new ArrayList<SoccerTO>();
	private ArrayList<SoccerTO> players_6 = new ArrayList<SoccerTO>();
	
	public SoccerDAO() {
		//db 연결정보 설정 및 드라이버 로딩
		String url = "jdbc:mysql://localhost:3307/uiproject";
		String user = "root";
		String password = "!123456";
		
		try {
			Class.forName( "org.mariadb.jdbc.Driver" );
			this.conn = DriverManager.getConnection(url, user, password);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	//엑셀에서 선수 파일 가져와서 DB에 저장하는 메서드
	public void insertPlayer() {
		try {
			//선수엑셀파일 가져오기
			BufferedReader br = new BufferedReader( new FileReader( "./player.csv" ) );
			String address;
			
			//sql문 선언 및 엑셀파일읽어서 sql문 실행
			String sql = 
			"insert into player(p_no, t_code, p_name, p_length, p_birth, p_weight, p_pos, p_backno) values(?, ?, ?, ?, ?, ?, ?, ?)";
			PreparedStatement pstmt = this.conn.prepareStatement(sql);
			while( (address = br.readLine() ) != null ) {
				String[] addresses = address.split(",");
				
				pstmt.setInt( 1, Integer.parseInt( addresses[0] ) );
				pstmt.setString( 2, addresses[1] );
				pstmt.setString( 3, addresses[2] );
				pstmt.setString( 4, addresses[3] );
				pstmt.setString( 5, addresses[4] );
				pstmt.setString( 6, addresses[5] );
				pstmt.setString( 7, addresses[6] );
				pstmt.setInt( 8, Integer.parseInt(addresses[7]) );
				
				ResultSet rs = pstmt.executeQuery();
				if ( rs != null ) rs.close();
			}
			
			if ( pstmt != null ) pstmt.close();
			if ( conn != null ) conn.close();
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	//5번패널: 선수 검색하는 메서드
	public ArrayList<SoccerTO> searchPlayer( String playerName ) {
		
		try {
			String sql = 
			"select p_no, t_code, p_name, p_length, p_birth, p_weight, p_pos, p_backno from player where p_name = ?";
			PreparedStatement pstmt = this.conn.prepareStatement(sql);
			pstmt.setString( 1, playerName );
			ResultSet rs = pstmt.executeQuery();
			
			while( rs.next() ) {
				SoccerTO to = new SoccerTO();
				to.setP_no( rs.getString( "p_no" ) );
				to.setT_code( rs.getString( "t_code" ) );
				to.setP_name( rs.getString( "p_name" ) );
				to.setP_length( rs.getString( "p_length" ) );
				to.setP_birth( rs.getString( "p_birth" ) );
				to.setP_weight( rs.getString( "p_weight" ) );
				to.setP_pos( rs.getString( "p_pos" ) );
				to.setP_backno( rs.getString( "p_backno" ) );
				players.add( to );
				
			}
			if( rs != null ) rs.close();
			if( pstmt != null ) pstmt.close();
			if( conn != null ) conn.close();

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NullPointerException e) {
			e.printStackTrace();
		}
		
		return players;
	}
	
	//5번 패널: 선수 삭제하는 메서드
	public void deletePlayer( int playerNum ) {
		
		try {
			String sqlDelete = "delete from player where p_no = ?";
			PreparedStatement pstmtDelete = this.conn.prepareStatement(sqlDelete);
			pstmtDelete.setInt(1, playerNum );
			ResultSet rsDelete = pstmtDelete.executeQuery();
			
			if( rsDelete != null ) rsDelete.close();
			if( pstmtDelete != null ) pstmtDelete.close();
			if( conn != null ) conn.close();
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	//6번패널: 선수 검색하는 메서드
	public ArrayList<SoccerTO> searchPlayer_6( Integer pNumber ) {
		
		try {
			String sql = 
			"select p_no, t_code, p_name, p_length, p_birth, p_weight, p_pos, p_backno from player where p_no = ?";
			PreparedStatement pstmt = this.conn.prepareStatement(sql);
			pstmt.setInt( 1, pNumber );
			ResultSet rs = pstmt.executeQuery();
			
			while( rs.next() ) {
				SoccerTO to = new SoccerTO();
				to.setP_no( rs.getString( "p_no" ) );
				to.setT_code( rs.getString( "t_code" ) );
				to.setP_name( rs.getString( "p_name" ) );
				to.setP_length( rs.getString( "p_length" ) );
				to.setP_birth( rs.getString( "p_birth" ) );
				to.setP_weight( rs.getString( "p_weight" ) );
				to.setP_pos( rs.getString( "p_pos" ) );
				to.setP_backno( rs.getString( "p_backno" ) );
				players_6.add( to );
				
			}
			if( rs != null ) rs.close();
			if( pstmt != null ) pstmt.close();
			if( conn != null ) conn.close();

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NullPointerException e) {
			e.printStackTrace();
		}
		
		return players_6;
	}

}

-InsertSoccer (실행 클래스)

package Pack_Player;

public class InsertSoccer {

	public static void main(String[] args) {
		SoccerDAO dao = new SoccerDAO();
		
		dao.insertPlayer();
		System.out.println( "선수 저장이 완료 되었습니다.");
	}
}

 

2.3 로그인과 회원가입 

-MainUI (최종 실행 클래스)

package Pack_UI;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import Pack_Model.TeamComboModel;
import Pack_Model._5_PlayerTableModel;
import Pack_Player.SoccerDAO;
import Pack_Player.SoccerTO;
import Pack_Model.LoginDAO;
import Pack_Model.TeamComboModel;

import javax.swing.JLabel;
import javax.swing.JOptionPane;

import java.awt.Font;
import java.awt.HeadlessException;

import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.swing.JPasswordField;
import java.awt.Panel;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.JTable;
import javax.swing.border.TitledBorder;
import javax.swing.border.EtchedBorder;
import java.awt.Color;

public class MainUI extends JFrame {

	private JPanel contentPane;
	

	Panel panel_Initial = new Panel();
	JPanel panel_CreateUser = new JPanel();
	JPanel panel_MainMenu = new JPanel();
	JPanel panel_InsertPlayer = new JPanel();
	JPanel panel_DeletePlayer = new JPanel();
	JPanel panel_SelectPlayer = new JPanel();

	JPanel panel_UpdatePlayer = new JPanel();
	
	private JTextField textField;
	private JPasswordField passwordField;
	private JTextField textCreateId;
	private JTextField textCreatePno1;
	private JTextField textCreateName;
	private JTextField textCreateYear;
	private JTextField textCreateMonth;
	private JTextField textCreateDay;
	private JTextField textCreatePno2;
	private JTextField textCreatePno3;
	private JPasswordField passwordFieldCreatePw;
	private final JButton btnMenuInsertPlayer = new JButton("\uC120 \uC218 \uCD94 \uAC00");
	private final JButton btnMenuDeletePlayer = new JButton("\uC120 \uC218 \uC0AD \uC81C");
	private final JButton btnMenuUpdatePlayer = new JButton("\uC120 \uC218 \uC218 \uC815");
	private final JButton btnMenuSelectPlayer = new JButton("\uC120 \uC218 \uAC80 \uC0C9");
	private final JButton btnMenuExit = new JButton("\uD504 \uB85C \uADF8 \uB7A8  \uC885 \uB8CC");
	private final JLabel lblNewLabel4_1 = new JLabel("\uC774\uB984");
	private final JLabel lblNewLabel4_2 = new JLabel("\uD300\uBA85");
	private final JLabel lblNewLabel4_3 = new JLabel("\uD0A4");
	private final JLabel lblNewLabel4_4 = new JLabel("\uC0DD\uB144\uC6D4\uC77C");
	private final JLabel lblNewLabel4_5 = new JLabel("\uBAB8\uBB34\uAC8C");
	private final JLabel lblNewLabel4_6 = new JLabel("\uD3EC\uC9C0\uC158");
	private final JLabel lblNewLabel4_7 = new JLabel("\uB4F1\uBC88\uD638");
	private final JTextField textField_4_PlayerName = new JTextField();
	private final JComboBox comboBox_4_Team = new JComboBox();
	private final JTextField textField_4_Height = new JTextField();
	private final JTextField textField_4_Year = new JTextField();
	private final JTextField textField_4_Month = new JTextField();
	private final JTextField textField_4_Day = new JTextField();
	private final JLabel lblNewLabel_3 = new JLabel("ex) 1990 01 01");
	private final JTextField textField_4_Weigth = new JTextField();
	private final JTextField textField_4_BackNum = new JTextField();
	private final JComboBox comboBox_4_Position = new JComboBox();
	private final JButton btn_4_Back = new JButton("\uBA54 \uB274 \uB85C  \uC774 \uB3D9");
	private final JButton btn_4_InsertPlayer = new JButton("\uC120 \uC218 \uCD94 \uAC00");
	private final JLabel lblNewLabel_5 = new JLabel("\uC120 \uC218 \uC774 \uB984");
	private final JTextField textField_5_PlayerName = new JTextField();
	private JTable table_5_SearchResult;
	
	private int playerNum = 0;
	private JTextField textField_7_PlayerName;
	private JTable table_7_ResultPlayer;
	private JTextField textField_6_P_no;
	private JTextField textField_6_Pname;
	private JTextField textField_6_Pheigth;
	private JTextField textField_6_Year;
	private JTextField textField_6_Weight;
	private JTextField textField_6_Backno;
	private JTextField textField_6_Month;
	private JTextField textField_6_Day;



	

	
	
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MainUI frame = new MainUI();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	
	public MainUI() {
		
		textField_5_PlayerName.setBounds(207, 94, 232, 25);
		textField_5_PlayerName.setColumns(10);
		textField_4_Year.setBounds(221, 215, 84, 21);
		textField_4_Year.setColumns(10);
		textField_4_Height.setBounds(221, 177, 215, 21);
		textField_4_Height.setColumns(10);
		textField_4_PlayerName.setBounds(221, 95, 215, 21);
		textField_4_PlayerName.setColumns(10);
		setTitle("K-\uB9AC\uADF8 \uCD95\uAD6C\uC120\uC218 \uB370\uC774\uD130 \uAD00\uB9AC \uD504\uB85C\uADF8\uB7A8");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 653, 540);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		setLocationRelativeTo(null);
		setResizable(false);
		contentPane.setLayout(null);
				
//ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ1. 로그인 패널ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
		panel_Initial.setBounds(0, 0, 637, 501);
		contentPane.add(panel_Initial);
		panel_Initial.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("\uCD95\uAD6C\uC120\uC218 \uAD00\uB9AC \uD504\uB85C\uADF8\uB7A8");
		lblNewLabel.setBounds(140, 28, 342, 35);
		lblNewLabel.setFont(new Font("휴먼둥근헤드라인", Font.BOLD, 30));
		panel_Initial.add(lblNewLabel);
		
		JLabel lblNewLabel_1 = new JLabel("ID");
		lblNewLabel_1.setBounds(179, 120, 18, 22);
		lblNewLabel_1.setFont(new Font("굴림", Font.BOLD, 18));
		panel_Initial.add(lblNewLabel_1);
		
		JLabel lblNewLabel_1_1 = new JLabel("PW");
		lblNewLabel_1_1.setBounds(179, 178, 27, 22);
		lblNewLabel_1_1.setFont(new Font("굴림", Font.BOLD, 18));
		panel_Initial.add(lblNewLabel_1_1);
		
		textField = new JTextField();
		textField.setBounds(230, 115, 199, 30);
		textField.setColumns(10);
		panel_Initial.add(textField);
		
		JButton btnLogin = new JButton("\uB85C \uADF8 \uC778");
		btnLogin.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				LoginDAO dao = new LoginDAO();
				try {
					if( dao.searchId( textField.getText() , passwordField.getText() ) ) {
						JOptionPane.showMessageDialog( MainUI.this, "로그인에 성공했습니다.");
						panel_Initial.setVisible( false );
						panel_CreateUser.setVisible( false );
						panel_MainMenu.setVisible( true );
					} else {
						JOptionPane.showMessageDialog( MainUI.this, "로그인에 실패했습니다. ID나 PW를 다시 확인해주세요");
					}
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		btnLogin.setBounds(256, 271, 150, 33);
		btnLogin.setFont(new Font("굴림", Font.BOLD, 20));
		panel_Initial.add(btnLogin);
		
		JButton btnCreateUser = new JButton("\uD68C \uC6D0 \uAC00 \uC785");
		btnCreateUser.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				panel_MainMenu.setVisible( false );
				panel_Initial.setVisible( false );
				panel_DeletePlayer.setVisible( false );
				panel_SelectPlayer.setVisible( false );
				panel_UpdatePlayer.setVisible( false );
				panel_InsertPlayer.setVisible( false );
				panel_CreateUser.setVisible( true );
				
			}
		});
		btnCreateUser.setBounds(256, 340, 150, 33);
		btnCreateUser.setFont(new Font("굴림", Font.BOLD, 20));
		panel_Initial.add(btnCreateUser);
		
		passwordField = new JPasswordField();
		passwordField.setBounds(230, 168, 199, 30);
		panel_Initial.add(passwordField);
		
//ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ2. 회원가입 패널ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
		panel_CreateUser.setBounds(0, 0, 637, 501);
		contentPane.add(panel_CreateUser);
		panel_CreateUser.setLayout(null);
		
		JLabel lblNewLabe2 = new JLabel("\uD68C \uC6D0 \uAC00 \uC785");
		lblNewLabe2.setBounds(233, 28, 187, 35);
		lblNewLabe2.setFont(new Font("휴먼둥근헤드라인", Font.BOLD, 30));
		panel_CreateUser.add(lblNewLabe2);
		
		JLabel lblNewLabel2_1 = new JLabel("ID");
		lblNewLabel2_1.setBounds(137, 94, 18, 22);
		lblNewLabel2_1.setFont(new Font("굴림", Font.BOLD, 18));
		panel_CreateUser.add(lblNewLabel2_1);
		
		textCreateId = new JTextField();
		textCreateId.setBounds(207, 96, 231, 21);
		panel_CreateUser.add(textCreateId);
		textCreateId.setColumns(10);
		
		JLabel lblNewLabel2_1_1 = new JLabel("PW");
		lblNewLabel2_1_1.setFont(new Font("굴림", Font.BOLD, 18));
		lblNewLabel2_1_1.setBounds(137, 135, 36, 22);
		panel_CreateUser.add(lblNewLabel2_1_1);
		
		JLabel lblNewLabel2_1_2 = new JLabel("\uC131\uBCC4");
		lblNewLabel2_1_2.setFont(new Font("굴림", Font.BOLD, 18));
		lblNewLabel2_1_2.setBounds(137, 224, 36, 22);
		panel_CreateUser.add(lblNewLabel2_1_2);
		
		textCreatePno1 = new JTextField();
		textCreatePno1.setColumns(10);
		textCreatePno1.setBounds(207, 308, 51, 21);
		panel_CreateUser.add(textCreatePno1);
		
		JLabel lblNewLabel2_1_3 = new JLabel("\uD734\uB300\uC804\uD654");
		lblNewLabel2_1_3.setFont(new Font("굴림", Font.BOLD, 18));
		lblNewLabel2_1_3.setBounds(116, 308, 79, 22);
		panel_CreateUser.add(lblNewLabel2_1_3);
		
		JLabel lblNewLabel2_1_4 = new JLabel("\uC0DD\uB144\uC6D4\uC77C");
		lblNewLabel2_1_4.setFont(new Font("굴림", Font.BOLD, 18));
		lblNewLabel2_1_4.setBounds(116, 266, 79, 22);
		panel_CreateUser.add(lblNewLabel2_1_4);
		
		textCreateName = new JTextField();
		textCreateName.setColumns(10);
		textCreateName.setBounds(207, 177, 231, 21);
		panel_CreateUser.add(textCreateName);
		
		JLabel lblNewLabel2_1_5 = new JLabel("\uC774\uB984");
		lblNewLabel2_1_5.setFont(new Font("굴림", Font.BOLD, 18));
		lblNewLabel2_1_5.setBounds(137, 177, 36, 22);
		panel_CreateUser.add(lblNewLabel2_1_5);
		
		JComboBox comboCreateGender = new JComboBox();
		comboCreateGender.setModel(new DefaultComboBoxModel(new String[] {"\uB0A8", "\uC5EC"}));
		comboCreateGender.setSelectedIndex(0);
		comboCreateGender.setBounds(207, 225, 119, 23);
		panel_CreateUser.add(comboCreateGender);
		
		JButton btnOverlapchk = new JButton("\uC911\uBCF5\uD655\uC778");
		btnOverlapchk.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				LoginDAO dao = new LoginDAO();
				try {
					if( dao.checkId( textCreateId.getText() ) ) {
						JOptionPane.showMessageDialog( MainUI.this, "ID가 중복됩니다. 다른 ID를 사용해주세요.");
						textCreateId.setText( "" );
					} else {
						JOptionPane.showMessageDialog( MainUI.this, "사용가능한 ID입니다.");
					}
					
				} catch (HeadlessException | SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		btnOverlapchk.setBounds(450, 95, 97, 23);
		panel_CreateUser.add(btnOverlapchk);
		
		JButton btnCreate = new JButton("\uD68C \uC6D0 \uAC00 \uC785");
		btnCreate.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				String birth = textCreateYear.getText() + "-" + textCreateMonth.getText() + "-" + textCreateDay.getText();
				String pno = textCreatePno1.getText() + "-" + textCreatePno2.getText() + "-" + textCreatePno3.getText();
				LoginDAO dao = new LoginDAO();
				try {
					dao.createUser( 
							textCreateId.getText(), passwordFieldCreatePw.getText(), textCreateName.getText()
							, (String)comboCreateGender.getSelectedItem(), birth, pno );
					JOptionPane.showMessageDialog( MainUI.this, "회원가입이 완료되었습니다.");
					panel_CreateUser.setVisible( false );
					panel_Initial.setVisible( true );
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					JOptionPane.showMessageDialog( MainUI.this, "입력정보를 정확히 입력하거나 ID중복을 확인해주세요.");
					
				}

			}
		});
		btnCreate.setFont(new Font("굴림", Font.PLAIN, 15));
		btnCreate.setBounds(341, 388, 135, 35);
		panel_CreateUser.add(btnCreate);
		
		textCreateYear = new JTextField();
		textCreateYear.setBounds(207, 268, 79, 21);
		panel_CreateUser.add(textCreateYear);
		textCreateYear.setColumns(10);
		
		textCreateMonth = new JTextField();
		textCreateMonth.setColumns(10);
		textCreateMonth.setBounds(296, 268, 65, 21);
		panel_CreateUser.add(textCreateMonth);
		
		textCreateDay = new JTextField();
		textCreateDay.setColumns(10);
		textCreateDay.setBounds(373, 268, 65, 21);
		panel_CreateUser.add(textCreateDay);
		
		JLabel lblNewLabel_2 = new JLabel("ex) 1999 09 09");
		lblNewLabel_2.setBounds(450, 271, 97, 15);
		panel_CreateUser.add(lblNewLabel_2);
		
		textCreatePno2 = new JTextField();
		textCreatePno2.setColumns(10);
		textCreatePno2.setBounds(270, 308, 79, 21);
		panel_CreateUser.add(textCreatePno2);
		
		textCreatePno3 = new JTextField();
		textCreatePno3.setColumns(10);
		textCreatePno3.setBounds(361, 308, 77, 21);
		panel_CreateUser.add(textCreatePno3);
		
		JLabel lblNewLabel_2_1 = new JLabel("ex) 010 1111 1111");
		lblNewLabel_2_1.setBounds(450, 311, 97, 15);
		panel_CreateUser.add(lblNewLabel_2_1);
		
		passwordFieldCreatePw = new JPasswordField();
		passwordFieldCreatePw.setBounds(207, 137, 231, 21);
		panel_CreateUser.add(passwordFieldCreatePw);
		
		JButton btnCreateBack = new JButton("\uB4A4 \uB85C \uAC00 \uAE30 ");
		btnCreateBack.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				panel_CreateUser.setVisible( false );
				panel_Initial.setVisible( true );
			}
		});
		btnCreateBack.setFont(new Font("굴림", Font.PLAIN, 15));
		btnCreateBack.setBounds(171, 388, 135, 35);
		panel_CreateUser.add(btnCreateBack);
		

		

				
//ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ3. 메뉴 패널ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
		
		panel_MainMenu.setBounds(0, 0, 637, 501);
		contentPane.add(panel_MainMenu);
		panel_MainMenu.setLayout(null);
		
		JLabel lblNewLabel3 = new JLabel("\uCD95\uAD6C\uC120\uC218 \uAD00\uB9AC \uD504\uB85C\uADF8\uB7A8");
		panel_MainMenu.add(lblNewLabel3);
		lblNewLabel3.setBounds(157, 27, 342, 35);
		lblNewLabel3.setFont(new Font("휴먼둥근헤드라인", Font.BOLD, 30));
		btnMenuInsertPlayer.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				panel_MainMenu.setVisible( false );
				panel_CreateUser.setVisible( false );
				panel_Initial.setVisible( false );
				panel_DeletePlayer.setVisible( false );
				panel_SelectPlayer.setVisible( false );
				panel_UpdatePlayer.setVisible( false );
				panel_InsertPlayer.setVisible( true );
				
			}
		});
		btnMenuInsertPlayer.setFont(new Font("휴먼둥근헤드라인", Font.PLAIN, 18));
		btnMenuInsertPlayer.setBounds(219, 100, 212, 48);
		
		panel_MainMenu.add(btnMenuInsertPlayer);
		btnMenuDeletePlayer.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				panel_MainMenu.setVisible( false );
				panel_CreateUser.setVisible( false );
				panel_Initial.setVisible( false );
				panel_SelectPlayer.setVisible( false );
				panel_UpdatePlayer.setVisible( false );
				panel_InsertPlayer.setVisible( false );
				panel_DeletePlayer.setVisible( true );
			}
		});
		btnMenuDeletePlayer.setFont(new Font("휴먼둥근헤드라인", Font.PLAIN, 18));
		btnMenuDeletePlayer.setBounds(219, 187, 212, 48);
		
		panel_MainMenu.add(btnMenuDeletePlayer);
		btnMenuUpdatePlayer.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				panel_MainMenu.setVisible( false );
				panel_CreateUser.setVisible( false );
				panel_Initial.setVisible( false );
				panel_SelectPlayer.setVisible( false );
				panel_InsertPlayer.setVisible( false );
				panel_DeletePlayer.setVisible( false );
				panel_UpdatePlayer.setVisible( true );
			}
		});
		btnMenuUpdatePlayer.setFont(new Font("휴먼둥근헤드라인", Font.PLAIN, 18));
		btnMenuUpdatePlayer.setBounds(219, 270, 212, 48);
		
		panel_MainMenu.add(btnMenuUpdatePlayer);
		btnMenuSelectPlayer.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				panel_MainMenu.setVisible( false );
				panel_CreateUser.setVisible( false );
				panel_Initial.setVisible( false );
				panel_InsertPlayer.setVisible( false );
				panel_DeletePlayer.setVisible( false );
				panel_UpdatePlayer.setVisible( false );
				panel_SelectPlayer.setVisible( true );
			}
		});
		btnMenuSelectPlayer.setFont(new Font("휴먼둥근헤드라인", Font.PLAIN, 18));
		btnMenuSelectPlayer.setBounds(219, 353, 212, 48);
		
		panel_MainMenu.add(btnMenuSelectPlayer);
		btnMenuExit.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				System.exit(0);
			}
		});
		btnMenuExit.setFont(new Font("휴먼둥근헤드라인", Font.PLAIN, 18));
		btnMenuExit.setBounds(219, 432, 212, 48);
		
		panel_MainMenu.add(btnMenuExit);
		
//ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ4. 선수 추가 패널ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
		
		panel_InsertPlayer.setBounds(0, 0, 637, 501);
		contentPane.add(panel_InsertPlayer);
		panel_InsertPlayer.setLayout(null);
		
		JLabel lblNewLabel4 = new JLabel("선 수 추 가");
		lblNewLabel4.setBounds(234, 20, 172, 35);
		lblNewLabel4.setFont(new Font("휴먼둥근헤드라인", Font.BOLD, 30));
		panel_InsertPlayer.add(lblNewLabel4);
		lblNewLabel4_1.setFont(new Font("맑은 고딕", Font.PLAIN, 15));
		lblNewLabel4_1.setBounds(144, 92, 65, 21);
		
		panel_InsertPlayer.add(lblNewLabel4_1);
		lblNewLabel4_2.setFont(new Font("맑은 고딕", Font.PLAIN, 15));
		lblNewLabel4_2.setBounds(144, 133, 65, 21);
		
		panel_InsertPlayer.add(lblNewLabel4_2);
		lblNewLabel4_3.setFont(new Font("맑은 고딕", Font.PLAIN, 15));
		lblNewLabel4_3.setBounds(144, 174, 65, 21);
		
		panel_InsertPlayer.add(lblNewLabel4_3);
		lblNewLabel4_4.setFont(new Font("맑은 고딕", Font.PLAIN, 15));
		lblNewLabel4_4.setBounds(144, 215, 65, 21);
		
		panel_InsertPlayer.add(lblNewLabel4_4);
		lblNewLabel4_5.setFont(new Font("맑은 고딕", Font.PLAIN, 15));
		lblNewLabel4_5.setBounds(144, 257, 65, 21);
		
		panel_InsertPlayer.add(lblNewLabel4_5);
		lblNewLabel4_6.setFont(new Font("맑은 고딕", Font.PLAIN, 15));
		lblNewLabel4_6.setBounds(144, 300, 65, 21);
		
		panel_InsertPlayer.add(lblNewLabel4_6);
		lblNewLabel4_7.setFont(new Font("맑은 고딕", Font.PLAIN, 15));
		lblNewLabel4_7.setBounds(144, 342, 65, 21);
		
		panel_InsertPlayer.add(lblNewLabel4_7);
		
		panel_InsertPlayer.add(textField_4_PlayerName);
		comboBox_4_Team.setBounds(221, 135, 215, 23);
		
		comboBox_4_Team.setModel( new TeamComboModel() );
		panel_InsertPlayer.add(comboBox_4_Team);
		
		panel_InsertPlayer.add(textField_4_Height);
		
		panel_InsertPlayer.add(textField_4_Year);
		textField_4_Month.setColumns(10);
		textField_4_Month.setBounds(317, 215, 53, 21);
		
		panel_InsertPlayer.add(textField_4_Month);
		textField_4_Day.setColumns(10);
		textField_4_Day.setBounds(375, 215, 61, 21);
		
		panel_InsertPlayer.add(textField_4_Day);
		lblNewLabel_3.setBounds(452, 215, 133, 15);
		
		panel_InsertPlayer.add(lblNewLabel_3);
		textField_4_Weigth.setColumns(10);
		textField_4_Weigth.setBounds(221, 257, 215, 21);
		
		panel_InsertPlayer.add(textField_4_Weigth);
		textField_4_BackNum.setColumns(10);
		textField_4_BackNum.setBounds(221, 342, 215, 21);
		
		panel_InsertPlayer.add(textField_4_BackNum);
		comboBox_4_Position.setModel(new DefaultComboBoxModel(new String[] {"GK", "FW", "DF", "MF"}));
		comboBox_4_Position.setSelectedIndex(0);
		comboBox_4_Position.setBounds(221, 298, 215, 23);
		
		panel_InsertPlayer.add(comboBox_4_Position);
		btn_4_Back.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				panel_InsertPlayer.setVisible( false );
				panel_MainMenu.setVisible( true );
			}
		});
		btn_4_Back.setFont(new Font("굴림", Font.PLAIN, 15));
		btn_4_Back.setBounds(144, 411, 133, 35);
		panel_InsertPlayer.add(btn_4_Back);
		
		btn_4_InsertPlayer.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				String p_birth = textField_4_Day.getText() + "/" + textField_4_Month.getText() + "/" + textField_4_Year.getText();
				String t_codes = (String)comboBox_4_Team.getSelectedItem();
				String[] t_code = t_codes.split("\\(");
				
				LoginDAO dao = new LoginDAO();
				try {
					dao.insertPlayer(
							t_code[0], textField_4_PlayerName.getText(), textField_4_Height.getText(), 
							p_birth, textField_4_Weigth.getText(), (String)comboBox_4_Position.getSelectedItem(), textField_4_BackNum.getText() );
					JOptionPane.showMessageDialog( MainUI.this, "선수 추가가 완료되었습니다.");
					textField_4_PlayerName.setText("");
					textField_4_BackNum.setText("");
					textField_4_Day.setText("");
					textField_4_Height.setText("");
					textField_4_Month.setText("");
					textField_4_Weigth.setText("");
					textField_4_Year.setText("");
					
					panel_InsertPlayer.setVisible( false );
					panel_MainMenu.setVisible( true );
					
				} catch (SQLException e1) {
					// TODO Auto-generated catch block
					JOptionPane.showMessageDialog( MainUI.this, "값이 이상합니다 다시 입력해주세요.");
					textField_4_PlayerName.setText("");
					textField_4_BackNum.setText("");
					textField_4_Day.setText("");
					textField_4_Height.setText("");
					textField_4_Month.setText("");
					textField_4_Weigth.setText("");
					textField_4_Year.setText("");
					e1.printStackTrace();
				}
			}
		});
		btn_4_InsertPlayer.setFont(new Font("굴림", Font.PLAIN, 15));
		btn_4_InsertPlayer.setBounds(335, 411, 133, 35);
		panel_InsertPlayer.add(btn_4_InsertPlayer);
		

		
		
//ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ5. 선수 삭제 패널ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
		
		panel_DeletePlayer.setBounds(0, 0, 637, 501);
		contentPane.add(panel_DeletePlayer);
		panel_DeletePlayer.setLayout(null);
		
		JLabel lblNewLabel5 = new JLabel("선 수 삭 제");
		lblNewLabel5.setBounds(233, 28, 172, 35);
		lblNewLabel5.setFont(new Font("휴먼둥근헤드라인", Font.BOLD, 30));
		panel_DeletePlayer.add(lblNewLabel5);
		lblNewLabel_5.setFont(new Font("휴먼둥근헤드라인", Font.PLAIN, 15));
		lblNewLabel_5.setBounds(104, 94, 91, 25);
		
		panel_DeletePlayer.add(lblNewLabel_5);
		
		panel_DeletePlayer.add(textField_5_PlayerName);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
		scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		scrollPane.setBounds(12, 142, 613, 259);
		panel_DeletePlayer.add(scrollPane);
		
		table_5_SearchResult = new JTable();
		scrollPane.setViewportView(table_5_SearchResult);
		
		JButton btn_5_Search = new JButton("\uAC80 \uC0C9");
		btn_5_Search.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				String playerName = textField_5_PlayerName.getText();
				
				table_5_SearchResult.setModel( new _5_PlayerTableModel( playerName ) );
				
			}
		});
		
		table_5_SearchResult.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				playerNum = Integer.parseInt( (String)table_5_SearchResult.getValueAt( table_5_SearchResult.getSelectedRow() , 0 ) ) ;
			}
		});

		btn_5_Search.setFont(new Font("굴림", Font.PLAIN, 15));
		btn_5_Search.setBounds(451, 94, 119, 25);
		panel_DeletePlayer.add(btn_5_Search);
		
		JButton btn_5_Menu = new JButton("\uBA54 \uB274");
		btn_5_Menu.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				panel_DeletePlayer.setVisible( false );
				panel_MainMenu.setVisible( true );
			}
		});
		btn_5_Menu.setFont(new Font("굴림", Font.PLAIN, 15));
		btn_5_Menu.setBounds(144, 411, 133, 35);
		panel_DeletePlayer.add(btn_5_Menu);
		
		JButton btn_5_Delete = new JButton("\uC120 \uC218 \uC0AD \uC81C");
		btn_5_Delete.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				SoccerDAO dao = new SoccerDAO();
				String playerName = textField_5_PlayerName.getText();
				dao.deletePlayer( playerNum );
				JOptionPane.showMessageDialog( MainUI.this, "선수 삭제가 완료되었습니다. 다시 검색해보세요.");
				
			}
		});
		btn_5_Delete.setFont(new Font("굴림", Font.PLAIN, 15));
		btn_5_Delete.setBounds(335, 411, 133, 35);
		panel_DeletePlayer.add(btn_5_Delete);
		
//ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ6. 선수 수정 패널ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
		

		JPanel panel = new JPanel();
		panel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, new Color(255, 255, 255), new Color(160, 160, 160)), "\uC120\uC218 \uC815\uBCF4\uB97C \uC218\uC815\uD574\uC8FC\uC138\uC694", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
		panel.setBounds(91, 105, 495, 283);
		panel_UpdatePlayer.add(panel);
		panel.setLayout(null);
		
		panel_UpdatePlayer.setBounds(0, 0, 637, 501);
		contentPane.add(panel_UpdatePlayer);
		panel_UpdatePlayer.setLayout(null);
		
		JLabel lblNewLabel_6_1 = new JLabel("\uC120 \uC218 \uC218 \uC815");
		lblNewLabel_6_1.setFont(new Font("HY헤드라인M", Font.BOLD, 30));
		lblNewLabel_6_1.setBounds(236, 10, 184, 47);
		panel_UpdatePlayer.add(lblNewLabel_6_1);
		
		JLabel lblNewLabel_7_2 = new JLabel("\uC120 \uC218 \uBC88 \uD638");
		lblNewLabel_7_2.setFont(new Font("굴림", Font.PLAIN, 15));
		lblNewLabel_7_2.setBounds(77, 72, 77, 23);
		panel_UpdatePlayer.add(lblNewLabel_7_2);
		
		textField_6_P_no = new JTextField();
		textField_6_P_no.setBounds(166, 71, 278, 23);
		panel_UpdatePlayer.add(textField_6_P_no);
		textField_6_P_no.setColumns(10);
		
		JComboBox comboBox_6_Position = new JComboBox();
		comboBox_6_Position.setBounds(75, 202, 268, 21);
		panel.add(comboBox_6_Position);
		comboBox_6_Position.setModel(new DefaultComboBoxModel(new String[] {"GK", "FW", "MF", "DF"}));		
		
		JComboBox comboBox_6_Tcode = new JComboBox();
		comboBox_6_Tcode.setBounds(75, 37, 268, 23);
		panel.add(comboBox_6_Tcode);
		
		JButton btn_6_SearchPlayer = new JButton("\uAC80 \uC0C9");
		btn_6_SearchPlayer.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				Integer pNumber = Integer.parseInt( textField_6_P_no.getText() );
				ArrayList<SoccerTO> to = new ArrayList<SoccerTO>();
				SoccerDAO dao = new SoccerDAO();
				to = dao.searchPlayer_6( pNumber );
				
				comboBox_6_Tcode.setModel( new TeamComboModel() );
				
				int i = 0;
				for( i = 0; i<comboBox_6_Tcode.getItemCount(); i++ ) {
					if ( comboBox_6_Tcode.getItemAt(i).toString().contains( to.get(0).getT_code( ) ) ) {
						break;
					}
				}
				int j = 0;
				for( j = 0; j<comboBox_6_Tcode.getItemCount(); j++ ) {
					if ( comboBox_6_Position.getItemAt(j).toString().contains( to.get(0).getP_pos() ) ) {
						break;
					}
				}
				String[] p_birth = to.get(0).getP_birth().split("/");
				
				comboBox_6_Tcode.setSelectedIndex( i );
				textField_6_Pname.setText( to.get(0).getP_name() );
				textField_6_Pheigth.setText( to.get(0).getP_length() );
				textField_6_Year.setText( p_birth[2] );
				textField_6_Month.setText( p_birth[1] );
				textField_6_Day.setText( p_birth[0] );
				textField_6_Weight.setText( to.get(0).getP_weight() );
				comboBox_6_Position.setSelectedIndex( j );
				textField_6_Backno.setText( to.get(0).getP_backno() );

			}
		});
		btn_6_SearchPlayer.setBounds(464, 72, 97, 23);
		panel_UpdatePlayer.add(btn_6_SearchPlayer);
		

		
		JLabel lblNewLabel_7_2_1 = new JLabel("\uD300\uCF54\uB4DC");
		lblNewLabel_7_2_1.setBounds(12, 37, 42, 18);
		panel.add(lblNewLabel_7_2_1);
		lblNewLabel_7_2_1.setFont(new Font("굴림", Font.PLAIN, 15));
		
		JLabel lblNewLabel_7_2_2 = new JLabel("\uC774 \uB984");
		lblNewLabel_7_2_2.setBounds(12, 71, 33, 18);
		panel.add(lblNewLabel_7_2_2);
		lblNewLabel_7_2_2.setFont(new Font("굴림", Font.PLAIN, 15));
		
		JLabel lblNewLabel_7_2_3 = new JLabel("\uD0A4");
		lblNewLabel_7_2_3.setBounds(12, 104, 51, 23);
		panel.add(lblNewLabel_7_2_3);
		lblNewLabel_7_2_3.setFont(new Font("굴림", Font.PLAIN, 15));
		
		JLabel lblNewLabel_7_2_3_1 = new JLabel("\uC0DD\uB144\uC6D4\uC77C");
		lblNewLabel_7_2_3_1.setBounds(12, 137, 56, 18);
		panel.add(lblNewLabel_7_2_3_1);
		lblNewLabel_7_2_3_1.setFont(new Font("굴림", Font.PLAIN, 15));
		
		JLabel lblNewLabel_7_2_3_2 = new JLabel("\uBAB8\uBB34\uAC8C");
		lblNewLabel_7_2_3_2.setBounds(12, 169, 42, 18);
		panel.add(lblNewLabel_7_2_3_2);
		lblNewLabel_7_2_3_2.setFont(new Font("굴림", Font.PLAIN, 15));
		
		JLabel lblNewLabel_7_2_3_2_1 = new JLabel("\uD3EC\uC9C0\uC158");
		lblNewLabel_7_2_3_2_1.setBounds(12, 202, 42, 18);
		panel.add(lblNewLabel_7_2_3_2_1);
		lblNewLabel_7_2_3_2_1.setFont(new Font("굴림", Font.PLAIN, 15));
		
		JLabel lblNewLabel_7_2_3_2_1_1 = new JLabel("\uB4F1\uBC88\uD638");
		lblNewLabel_7_2_3_2_1_1.setBounds(12, 236, 42, 18);
		panel.add(lblNewLabel_7_2_3_2_1_1);
		lblNewLabel_7_2_3_2_1_1.setFont(new Font("굴림", Font.PLAIN, 15));
		
		textField_6_Pname = new JTextField();
		textField_6_Pname.setBounds(75, 71, 268, 21);
		panel.add(textField_6_Pname);
		textField_6_Pname.setColumns(10);
		
		textField_6_Pheigth = new JTextField();
		textField_6_Pheigth.setBounds(75, 104, 268, 21);
		panel.add(textField_6_Pheigth);
		textField_6_Pheigth.setColumns(10);
		
		textField_6_Year = new JTextField();
		textField_6_Year.setBounds(75, 137, 116, 21);
		panel.add(textField_6_Year);
		textField_6_Year.setColumns(10);
		
		textField_6_Weight = new JTextField();
		textField_6_Weight.setBounds(75, 169, 268, 21);
		panel.add(textField_6_Weight);
		textField_6_Weight.setColumns(10);
		
		textField_6_Backno = new JTextField();
		textField_6_Backno.setBounds(75, 236, 268, 21);
		panel.add(textField_6_Backno);
		textField_6_Backno.setColumns(10);
		

		

		
		textField_6_Month = new JTextField();
		textField_6_Month.setBounds(203, 138, 62, 21);
		panel.add(textField_6_Month);
		textField_6_Month.setColumns(10);
		
		textField_6_Day = new JTextField();
		textField_6_Day.setBounds(277, 138, 66, 21);
		panel.add(textField_6_Day);
		textField_6_Day.setColumns(10);
		
		JLabel lblNewLabel_7_2_1_1 = new JLabel("ex) 1999 01 01");
		lblNewLabel_7_2_1_1.setBounds(355, 141, 137, 23);
		panel.add(lblNewLabel_7_2_1_1);
		lblNewLabel_7_2_1_1.setFont(new Font("굴림", Font.PLAIN, 15));
		
		JButton btn_6_Menu = new JButton("\uBA54 \uB274");
		btn_6_Menu.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				panel_UpdatePlayer.setVisible( false );
				panel_MainMenu.setVisible( true );
			}
		});
		btn_6_Menu.setFont(new Font("굴림", Font.BOLD, 23));
		btn_6_Menu.setBounds(121, 410, 158, 47);
		panel_UpdatePlayer.add(btn_6_Menu);
		
		JButton btn_6_UpdatePlayer = new JButton("\uC120 \uC218 \uC218 \uC815");
		btn_6_UpdatePlayer.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				LoginDAO dao = new LoginDAO();
				String[] t_code = comboBox_6_Tcode.getSelectedItem().toString().split("\\("); 
				String t_birth = textField_6_Day.getText() + "/" + textField_6_Month.getText() + "/" + textField_6_Year.getText();
				try {
					dao.updatePlayer( Integer.parseInt(textField_6_P_no.getText()), t_code[0], textField_6_Pname.getText(), 
							textField_6_Pheigth.getText(), t_birth, textField_6_Weight.getText(), 
							(String)comboBox_6_Position.getSelectedItem(), textField_6_Backno.getText() );
					
					JOptionPane.showMessageDialog(MainUI.this, "선수 수정이 완료되었습니다. 메뉴에서 선수검색을 해보세요.");
					panel_UpdatePlayer.setVisible( false );
					panel_MainMenu.setVisible( true );
					
				} catch (NumberFormatException | SQLException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});
		btn_6_UpdatePlayer.setFont(new Font("굴림", Font.BOLD, 23));
		btn_6_UpdatePlayer.setBounds(332, 410, 158, 47);
		panel_UpdatePlayer.add(btn_6_UpdatePlayer);
		
		
		
		
//ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ7. 선수 검색 패널ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
		
		
		panel_SelectPlayer.setBounds(0, 0, 637, 501);
		contentPane.add(panel_SelectPlayer);
		panel_SelectPlayer.setLayout(null);
		
		JLabel lblNewLabel_7_1 = new JLabel("\uC120 \uC218 \uAC80 \uC0C9");
		lblNewLabel_7_1.setFont(new Font("HY헤드라인M", Font.BOLD, 30));
		lblNewLabel_7_1.setBounds(240, 28, 196, 52);
		panel_SelectPlayer.add(lblNewLabel_7_1);
		
		JLabel lblNewLabel_7 = new JLabel("\uC774 \uB984");
		lblNewLabel_7.setFont(new Font("굴림", Font.PLAIN, 18));
		lblNewLabel_7.setBounds(121, 110, 74, 22);
		panel_SelectPlayer.add(lblNewLabel_7);
		
		textField_7_PlayerName = new JTextField();
		textField_7_PlayerName.setBounds(186, 110, 250, 23);
		panel_SelectPlayer.add(textField_7_PlayerName);
		textField_7_PlayerName.setColumns(10);
		
		JScrollPane scrollPane_1 = new JScrollPane();
		scrollPane_1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
		scrollPane_1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		scrollPane_1.setBounds(12, 165, 613, 241);
		panel_SelectPlayer.add(scrollPane_1);
		
		table_7_ResultPlayer = new JTable();
		scrollPane_1.setViewportView(table_7_ResultPlayer);
		
		JButton btn_7_SearchPlayer = new JButton("\uAC80 \uC0C9");
		btn_7_SearchPlayer.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				String pName = textField_7_PlayerName.getText();
				table_7_ResultPlayer.setModel( new _5_PlayerTableModel( pName ) );
			}
		});
		btn_7_SearchPlayer.setFont(new Font("굴림", Font.PLAIN, 15));
		btn_7_SearchPlayer.setBounds(448, 110, 97, 24);
		panel_SelectPlayer.add(btn_7_SearchPlayer);
		
		JButton btn_7_Menu = new JButton("\uBA54 \uB274");
		btn_7_Menu.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				panel_SelectPlayer.setVisible( false );
				panel_MainMenu.setVisible( true );
			}
		});
		btn_7_Menu.setFont(new Font("굴림", Font.PLAIN, 20));
		btn_7_Menu.setBounds(240, 427, 146, 52);
		panel_SelectPlayer.add(btn_7_Menu);
//ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ끝ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
	}
}

-LoginTO

package Pack_Model;

public class LoginTO {
	private String u_id;
	private String u_pass;
	private String u_name;
	private String u_gender;
	private String u_birth;
	private String u_pno;
	
	//생성자
	public LoginTO() {
	}
	
	//Setter and Getter
	public void setU_id(String u_id) {
		this.u_id = u_id;
	}
	public void setU_pass(String u_pass) {
		this.u_pass = u_pass;
	}
	public void setU_name(String u_name) {
		this.u_name = u_name;
	}
	public void setU_gender(String u_gender) {
		this.u_gender = u_gender;
	}
	public void setU_birth(String u_birth) {
		this.u_birth = u_birth;
	}
	public void setU_pno(String u_pno) {
		this.u_pno = u_pno;
	}

	public String getU_id() {
		return u_id;
	}
	public String getU_pass() {
		return u_pass;
	}
	public String getU_name() {
		return u_name;
	}
	public String getU_gender() {
		return u_gender;
	}
	public String getU_birth() {
		return u_birth;
	}
	public String getU_pno() {
		return u_pno;
	}
}

-LoginDAO

package Pack_Model;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

public class LoginDAO {
	private boolean idCheck = false;
	private Connection conn = null;
	
	public LoginDAO() {
		//db 연결정보 설정 및 드라이버 로딩
		String url = "jdbc:mysql://localhost:3307/uiproject";
		String user = "root";
		String password = "!123456";
		
		try {
			Class.forName( "org.mariadb.jdbc.Driver" );
			this.conn = DriverManager.getConnection(url, user, password);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	//1. 로그인창: 아이디 비번 확인 메서드
	public boolean searchId( String id, String pw ) throws SQLException {
		//sql문 선언 및 실행
		String sql  = "select u_id, u_pass from user";
		PreparedStatement pstmt = this.conn.prepareStatement(sql);
		ResultSet rs = pstmt.executeQuery();
		while ( rs.next() ) {
			if ( rs.getString( "u_id" ).equals( id ) ) {
				if ( rs.getString( "u_pass" ).equals( pw ) ) {
					idCheck = true;
				}
			}
		}
		if( rs != null ) rs.close();
		if( pstmt != null ) pstmt.close();
		if( conn != null ) conn.close();
		
		return idCheck;
	}
	
	//2. 회원가입창: 아이디 중복확인 메서드
	public boolean checkId( String id ) throws SQLException {
		//sql문 선언 및 실행
		String sql  = "select u_id from user";
		PreparedStatement pstmt = this.conn.prepareStatement(sql);
		ResultSet rs = pstmt.executeQuery();
		while ( rs.next() ) {
			if ( rs.getString( "u_id" ).equals( id ) ) {
					idCheck = true;
			} 
		}
		if( rs != null ) rs.close();
		if( pstmt != null ) pstmt.close();
		if( conn != null ) conn.close();
		
		return idCheck;
	}
	
	//2. 회원가입창: 회원가입메서드
	public void createUser(String u_id, String u_pass, String u_name, String u_gender, String u_birth, String u_pno) 
			throws SQLException {
		String sql = "insert into user values (?, ?, ?, ?, ?, ?)";
		PreparedStatement pstmt = this.conn.prepareStatement(sql);
		pstmt.setString(1, u_id);
		pstmt.setString(2, u_pass);
		pstmt.setString(3, u_name);
		pstmt.setString(4, u_gender);
		pstmt.setString(5, u_birth);
		pstmt.setString(6, u_pno);
		ResultSet rs = pstmt.executeQuery();
		
		if( rs != null ) rs.close();
		if( pstmt != null ) pstmt.close();
		if( conn != null ) conn.close();
	}
	
	//4. 선수추가창: 선수추가 메서드
	public void insertPlayer(
			String t_code, String p_name, String p_length, String p_birth, String p_weight, String p_pos, String p_backno) 
					throws SQLException {
		
		//선수 마지막 번호 가져오는 sql
		int lastNum = 0;
		String sqlNum = "select p_no from player order by p_no desc limit 1";
		PreparedStatement pstmt = this.conn.prepareStatement(sqlNum);
		ResultSet rs = pstmt.executeQuery();
		rs.next();
		lastNum = rs.getInt(1) + 1;
		
		
		//선수 추가하기
		String sql = 
		"insert into player(p_no, t_code, p_name, p_length, p_birth, p_weight, p_pos, p_backno) values(?, ?, ?, ?, ?, ?, upper(?), ?)";
		PreparedStatement pstmt1 = this.conn.prepareStatement(sql);
		pstmt1.setInt(1, lastNum );
		pstmt1.setString(2, t_code );
		pstmt1.setString(3, p_name );
		pstmt1.setString(4, p_length + "Cm" );
		pstmt1.setString(5, p_birth );
		pstmt1.setString(6, p_weight + "Kg" );
		pstmt1.setString(7, p_pos );
		pstmt1.setInt(8, Integer.parseInt( p_backno ) );
		ResultSet rs1 = pstmt1.executeQuery();
		
		if( rs1 != null ) rs1.close();
		if( pstmt1 != null ) pstmt1.close();
		if( rs != null ) rs.close();
		if( pstmt != null ) pstmt.close();
		if( conn != null ) conn.close();
	}
	
	//6. 선수수정창: 선수수정 메서드
	public void updatePlayer( Integer p_no,
			String t_code, String p_name, String p_length, String p_birth, String p_weight, String p_pos, String p_backno) 
					throws SQLException{

		//선수 추가하기
		String sql = 
		"update player set t_code=?, p_name=?, p_length=?, p_birth=?, p_weight=?, p_pos=?, p_backno=? where p_no = ? ";
		PreparedStatement pstmt1 = this.conn.prepareStatement(sql);
		pstmt1.setString(1, t_code );
		pstmt1.setString(2, p_name );
		pstmt1.setString(3, p_length );
		pstmt1.setString(4, p_birth );
		pstmt1.setString(5, p_weight );
		pstmt1.setString(6, p_pos );
		pstmt1.setString(7, p_backno );
		pstmt1.setInt(8, p_no );
		ResultSet rs1 = pstmt1.executeQuery();
		
		if( rs1 != null ) rs1.close();
		if( pstmt1 != null ) pstmt1.close();
		if( conn != null ) conn.close();
	}
	
}

 

2.4 각종 기능 구현

기능에 대한 메서드는 LoginDAO와 SoccerDAO, TeamDAO 안에 선언되어 있음

-_5_PlayerTableModel

package Pack_Model;

import java.util.ArrayList;

import javax.swing.table.AbstractTableModel;

import Pack_Player.SoccerDAO;
import Pack_Player.SoccerTO;

public class _5_PlayerTableModel extends AbstractTableModel {
	private String[] columnNames = {"선수번호", "팀코드", "선수명", "키", "생년월일", "몸무게", "포지션", "등번호"};
	private ArrayList<SoccerTO> players;
	
	public _5_PlayerTableModel( String playerName) {
		SoccerDAO dao = new SoccerDAO();
		players = dao.searchPlayer( playerName );
	}

	@Override
	public String getColumnName(int column) {
		return columnNames[column];
	}
	
	@Override
	public int getRowCount() {
		return players.size();
	}

	@Override
	public int getColumnCount() {
		return 8;
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		String result = "";
		SoccerTO to = players.get( rowIndex );
		switch ( columnIndex ) {
		case 0:
			result = to.getP_no();
			break;
		case 1:
			result = to.getT_code();
			break;
		case 2:
			result = to.getP_name();
			break;
		case 3:
			result = to.getP_length();
			break;
		case 4:
			result = to.getP_birth();
			break;
		case 5:
			result = to.getP_weight();
			break;
		case 6:
			result = to.getP_pos();
			break;
		case 7:
			result = to.getP_backno();
			break;
		}
		
		return result;
	}
}

-TeamComboModel

package Pack_Model;

import java.util.ArrayList;
import javax.swing.DefaultComboBoxModel;

import Pack_Team.TeamDAO;
import Pack_Team.TeamTO;

public class TeamComboModel extends DefaultComboBoxModel<Object> {
	ArrayList<TeamTO> teams = new ArrayList<TeamTO>();

	public TeamComboModel() {
		TeamDAO dao = new TeamDAO();
		teams = dao.selectTeam();
	}

	@Override
	public int getSize() {
		return teams.size();
	}

	@Override
	public Object getElementAt(int index) {
		String resultTeam = teams.get(index).getT_code() + "(" + teams.get(index).getT_name() + ")";
		return resultTeam;
	}
}

 

3. 최종 결과

 

 

 

 

 

정말 CRUD 기능만 구현을 했고 코드는 정리가 필요한 상태.

이후에 약간의 기능 및 디자인을 첨가해보자..ㅎ

 

728x90
반응형
Comments