모바일 오유 바로가기
http://m.todayhumor.co.kr
분류 게시판
베스트
  • 베스트오브베스트
  • 베스트
  • 오늘의베스트
  • 유머
  • 유머자료
  • 유머글
  • 이야기
  • 자유
  • 고민
  • 연애
  • 결혼생활
  • 좋은글
  • 자랑
  • 공포
  • 멘붕
  • 사이다
  • 군대
  • 밀리터리
  • 미스터리
  • 술한잔
  • 오늘있잖아요
  • 투표인증
  • 새해
  • 이슈
  • 시사
  • 시사아카이브
  • 사회면
  • 사건사고
  • 생활
  • 패션
  • 패션착샷
  • 아동패션착샷
  • 뷰티
  • 인테리어
  • DIY
  • 요리
  • 커피&차
  • 육아
  • 법률
  • 동물
  • 지식
  • 취업정보
  • 식물
  • 다이어트
  • 의료
  • 영어
  • 맛집
  • 추천사이트
  • 해외직구
  • 취미
  • 사진
  • 사진강좌
  • 카메라
  • 만화
  • 애니메이션
  • 포니
  • 자전거
  • 자동차
  • 여행
  • 바이크
  • 민물낚시
  • 바다낚시
  • 장난감
  • 그림판
  • 학술
  • 경제
  • 역사
  • 예술
  • 과학
  • 철학
  • 심리학
  • 방송연예
  • 연예
  • 음악
  • 음악찾기
  • 악기
  • 음향기기
  • 영화
  • 다큐멘터리
  • 국내드라마
  • 해외드라마
  • 예능
  • 팟케스트
  • 방송프로그램
  • 무한도전
  • 더지니어스
  • 개그콘서트
  • 런닝맨
  • 나가수
  • 디지털
  • 컴퓨터
  • 프로그래머
  • IT
  • 안티바이러스
  • 애플
  • 안드로이드
  • 스마트폰
  • 윈도우폰
  • 심비안
  • 스포츠
  • 스포츠
  • 축구
  • 야구
  • 농구
  • 바둑
  • 야구팀
  • 삼성
  • 두산
  • NC
  • 넥센
  • 한화
  • SK
  • 기아
  • 롯데
  • LG
  • KT
  • 메이저리그
  • 일본프로야구리그
  • 게임1
  • 플래시게임
  • 게임토론방
  • 엑스박스
  • 플레이스테이션
  • 닌텐도
  • 모바일게임
  • 게임2
  • 던전앤파이터
  • 마비노기
  • 마비노기영웅전
  • 하스스톤
  • 히어로즈오브더스톰
  • gta5
  • 디아블로
  • 디아블로2
  • 피파온라인2
  • 피파온라인3
  • 워크래프트
  • 월드오브워크래프트
  • 밀리언아서
  • 월드오브탱크
  • 블레이드앤소울
  • 검은사막
  • 스타크래프트
  • 스타크래프트2
  • 베틀필드3
  • 마인크래프트
  • 데이즈
  • 문명
  • 서든어택
  • 테라
  • 아이온
  • 심시티5
  • 프리스타일풋볼
  • 스페셜포스
  • 사이퍼즈
  • 도타2
  • 메이플스토리1
  • 메이플스토리2
  • 오버워치
  • 오버워치그룹모집
  • 포켓몬고
  • 파이널판타지14
  • 배틀그라운드
  • 기타
  • 종교
  • 단어장
  • 자료창고
  • 운영
  • 공지사항
  • 오유운영
  • 게시판신청
  • 보류
  • 임시게시판
  • 메르스
  • 세월호
  • 원전사고
  • 2016리오올림픽
  • 2018평창올림픽
  • 코로나19
  • 2020도쿄올림픽
  • 게시판찾기
  • 오유인페이지
    개인차단 상태
    님의
    개인페이지입니다
    가입 : 10-04-30
    방문 : 2162회
    닉네임변경 이력
    회원차단
    회원차단해제
    게시물ID : programmer_6120
    작성자 :
    추천 : 0
    조회수 : 508
    IP : 14.50.***.184
    댓글 : 0개
    등록시간 : 2014/10/21 23:38:10
    http://todayhumor.com/?programmer_6120 모바일
    엊그제 질문한 패널 문제 해결했습니당! + 질문 하나만 더 해도 될까요?
    옵션
    • 베스트금지
    • 본인삭제금지
    package Project;
    import javax.swing.*;
    import javax.swing.text.MaskFormatter;
    import Project.admin_Login.EventHandler;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.text.ParseException;
    public class register {
     JFrame f = new JFrame();
     JLabel headLabel, nameLabel, idLabel, pwLabel1, pwLabel2, postLabel1, postLabel2, addressLabel, telLabel1, telLabel2, handLabel1, handLabel2, juminLabel1, juminLabel2;
     JTextField nameField, idField, postField1, postField2, addressField, telField1, telField2, handField1, handField2, juminField1, juminField2;
     TextField pwField1, pwField2;
     JButton checkButton, searchButton, joinButton, cancelButton;
     String []company ={"SKT","KTF","LG"};
     JComboBox brandComboBox;
     String []number ={"010","011","016","017","018","019"};
     JComboBox numberComboBox;
     JPanel topPanel, centerPanel, clPanel, crPanel, Panel, namePanel, pwPanel1, pwPanel2, addressPanel,
       idPanel, postPanel, telPanel, handPanel, juminPanel, checkPanel;
     JComboBox localComboBox;
     String []local ={"02","031", "032", "033", "041", "042", "043", "044", "051", "052", "053", "054", "055", "061", "062", "063", "064"};
     MaskFormatter fourmatter, sevenmatter, sixmatter = null;
     JFormattedTextField jumin, jumin2, tel, tel2, hand, hand2;
     
     
     register(String title){
      
      try {
       fourmatter = new MaskFormatter("####");
      } catch (ParseException e) {
       e.printStackTrace();
      }
      try{
       sixmatter = new MaskFormatter("######");
      }catch (ParseException e) {
       e.printStackTrace();
      }
      try{
       sevenmatter = new MaskFormatter("#######");
      }catch (ParseException e) {
       e.printStackTrace();
      }
      
      tel = new JFormattedTextField(fourmatter);
      tel2 = new JFormattedTextField(fourmatter);
      jumin = new JFormattedTextField(sixmatter);
      jumin2 = new JFormattedTextField(sevenmatter);
      hand = new JFormattedTextField(fourmatter);
      hand2 = new JFormattedTextField(fourmatter);
      
      headLabel = new JLabel("회원가입");
      nameLabel = new JLabel("이름 : ", JLabel.RIGHT);
      idLabel = new JLabel("아이디 : ", JLabel.RIGHT);
      pwLabel1 = new JLabel("패스워드 : ", JLabel.RIGHT);
      pwLabel2 = new JLabel("패스워드 확인: ",JLabel.RIGHT);
      juminLabel1 = new JLabel("주민번호 : ", JLabel.RIGHT);
      juminLabel2 = new JLabel("-");
      postLabel1 = new JLabel("우편번호 : ", JLabel.RIGHT);
      postLabel2 = new JLabel("-");
      addressLabel = new JLabel("주소 : ", JLabel.RIGHT);
      telLabel1 = new JLabel("전화번호 : ", JLabel.RIGHT);
      telLabel2 = new JLabel("-");
      handLabel1 = new JLabel("핸드폰 : ", JLabel.RIGHT);
      handLabel2 = new JLabel(" - ");
      nameField = new JTextField(10);
      idField = new JTextField(10);
      postField1 = new JTextField(3);
      postField2 = new JTextField(3);
      addressField = new JTextField(23);
      
      
      
      
      
      pwField1 = new TextField(10);
      pwField1.setEchoChar('*');
      pwField2 = new TextField(10);
      pwField2.setEchoChar('*');
      
      
       
      checkButton = new JButton("중복검사");
      searchButton = new JButton("주소검색");
      joinButton = new JButton("가입");
      cancelButton = new JButton("취소");
      
      idField.addActionListener(new EventHandler1());
      pwField1.addActionListener(new EventHandler1());
      pwField2.addActionListener(new EventHandler1());
      joinButton.addActionListener(new EventHandler1());
      checkButton.addActionListener(new EventHandler1());
      
      
      brandComboBox = new JComboBox(company);
      numberComboBox = new JComboBox(number);
      localComboBox = new JComboBox(local);
      
      topPanel = new JPanel(new GridLayout(1,1,5,5));
      centerPanel = new JPanel(new GridLayout(1,2));
      crPanel = new JPanel(new GridLayout(9,1));
      clPanel = new JPanel(new GridLayout(9,1));
      namePanel = new JPanel(new FlowLayout());
      namePanel.setLayout(new FlowLayout(FlowLayout.LEFT));
      pwPanel1 = new JPanel(new FlowLayout());
      pwPanel1.setLayout(new FlowLayout(FlowLayout.LEFT));
      pwPanel2 = new JPanel(new FlowLayout());
      pwPanel2.setLayout(new FlowLayout(FlowLayout.LEFT));
      idPanel = new JPanel(new FlowLayout());
      idPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
      postPanel = new JPanel(new FlowLayout());
      postPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
      addressPanel = new JPanel(new FlowLayout());
      addressPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
      telPanel = new JPanel(new FlowLayout());
      telPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
      handPanel = new JPanel(new FlowLayout());
      handPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
      juminPanel = new JPanel(new FlowLayout());
      juminPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
      checkPanel = new JPanel(new FlowLayout());
      
      Panel = new JPanel(new BorderLayout(0,20));
      
      topPanel.add(headLabel);
      idPanel.add(idField);
      idPanel.add(checkButton);
      postPanel.add(postField1);
      postPanel.add(postLabel2);
      postPanel.add(postField2);
      postPanel.add(searchButton);
      addressPanel.add(addressField);
      telPanel.add(localComboBox);
      telPanel.add(tel);
      telPanel.add(telLabel2);
      telPanel.add(tel2);
      handPanel.add(brandComboBox);
      handPanel.add(numberComboBox);
      handPanel.add(hand);
      handPanel.add(handLabel2);
      handPanel.add(hand2);
      juminPanel.add(jumin);
      juminPanel.add(juminLabel2);
      juminPanel.add(jumin2);
      pwPanel1.add(pwField1);
      pwPanel2.add(pwField2);
      namePanel.add(nameField);
      crPanel.add(namePanel);
      crPanel.add(juminPanel);
      crPanel.add(idPanel);
      crPanel.add(pwPanel1);
      crPanel.add(pwPanel2);
      crPanel.add(postPanel);
      crPanel.add(addressPanel);
      crPanel.add(telPanel);
      crPanel.add(handPanel);
      clPanel.add(nameLabel);
      clPanel.add(juminLabel1);
      clPanel.add(idLabel);
      clPanel.add(pwLabel1);
      clPanel.add(pwLabel2);
      clPanel.add(postLabel1);
      clPanel.add(addressLabel);
      clPanel.add(telLabel1);
      clPanel.add(handLabel1);
      
      centerPanel.add(crPanel);
      checkPanel.add(joinButton);
      checkPanel.add(cancelButton);
      Panel.add(checkPanel, "South");
      Panel.add(centerPanel, "Center");
      Panel.add(topPanel, "North");
      Panel.add(clPanel, "West");
      f.add(Panel);
      
      f.setResizable(false);
      f.setSize(350, 420);
      f.setVisible(true);
     }
     public static void main(String[] args) {
      // TODO Auto-generated method stub
      register r = new register("회원가입");
     }
     class EventHandler1 implements ActionListener{
      public void actionPerformed(ActionEvent e) {
       if(e.getActionCommand().equals("가입")){
        String id = idField.getText();
        String pw = pwField1.getText();
        String name = nameField.getText();
        String post = postField1.getText() + postField2.getText();
        String address = addressField.getText();
        String tel3 =  localComboBox.getSelectedItem()+tel.getText() +tel2.getText();
        String hand3 = (String)brandComboBox.getSelectedItem()+numberComboBox.getSelectedItem()+ hand.getText() + hand2.getText();
        String jumin3 = jumin.getText()+ jumin2.getText();   
       
        Connection conn= null;
        Statement stmt= null;
        ResultSet rs= null;
        String query= null;
        int result;  
        try{
         query= "insert into user values ('" +name +"', '"+jumin3+"', '"+id+"', '"+pw+"', '"+post+"', '"+address+"', '"+tel3+"', '"+hand3+"')";
          
         //1. Loading driver
         Class.forName("com.mysql.jdbc.Driver");
         //2. Connecting to a DB
         conn= DriverManager.getConnection("jdbc:mysql://localhost:3306/project",
          "root", "12345678");
         //3. Creating statement object
         stmt= conn.createStatement();
         //B. For printing table data
         result= stmt.executeUpdate(query);
        
    //     if(rs.next()){
    //      System.out.println("중복된 아이디가 있습니다.");
    //     }else{
    //      System.out.println("이 아이디는 사용 가능합니다!");
    //     }
        }catch(ClassNotFoundException e1){
         System.out.println("Couldn't load database driver: "+ e1.getMessage());;
        }catch(SQLException e2){
         System.out.println("SQLException caught: "+ e2.getMessage());
        }finally{
        //6. Closing db connection
         try{
          if(conn!= null)
           conn.close();
         }catch(SQLException ignored){}
        }
       }else if(e.getActionCommand().equals("중복검사")){
        Connection conn= null;
        Statement stmt= null;
        ResultSet rs= null;
        String query= null;
        String id = idField.getText();
        try{
         query= "select * from user where id='" + id  + "'";
         //1. Loading driver
         Class.forName("com.mysql.jdbc.Driver");
         //2. Connecting to a DB
         conn= DriverManager.getConnection("jdbc:mysql://localhost:3306/project",
           "root", "12345678");
         //3. Creating statement object
         stmt= conn.createStatement();
         //B. For printing table data
         rs= stmt.executeQuery(query);
         
         if(rs.next()){
          System.out.println("아이디가 중복됩니다. 다른 아이디를 사용해 주세요");      
         }else{
          System.out.println("사용 가능한 아이디 입니다.");
          
         }
        }catch(ClassNotFoundException e1){
          System.out.println("Couldn't load database driver: "+ e1.getMessage());;
        }catch(SQLException e2){
          System.out.println("SQLException caught: "+ e2.getMessage());
        }finally{
         //6. Closing db connection
         try{
          if(conn!= null)
           conn.close();
         }catch(SQLException ignored){}
        }
       }
      }
     }
    }
    1244.jpg
     
     
    엊그제 질문한 패널에 공간이 많이 남는 다고 말씀드린 문제는 위치를 CENTER 에서 WEST로 잡는걸로 해결하였습니다. 감사합니다.
     
    그런데 주민 등록 번호와 전화번호 핸드폰 번호에 각각 6자 7자 4자씩의 제한과 문자 입력 방지를 위해
     
    MaskForMatter와 JFormattedTextField 를 이용하여 해결하였는데요 패널을 FlowLayout 으로 잡아놔서인지 JFormattedTextField 의 입력 공간이 보기와 같이 너무 작아져서요... 한두자만 보이고 글자가 안보이는 문제가 생겼습니다 ㅜㅜ.
    그래서 BorderLayout 으로  잡아봣으나 주민번호 : [텍스트 필드] - [텍스트 필드] 에서 주민번호: [텍스트필드] 로 변하며 앞쪽의 텍스트 필드와 -(바)가 사라지는 문제가 생겼습니다.
     
     
    혹시 어떤식으로 해결해야 하는지 방향만이라도 잡아 주실 수 있나요?
     


    이 게시물을 추천한 분들의 목록입니다.
    푸르딩딩:추천수 3이상 댓글은 배경색이 바뀝니다.
    (단,비공감수가 추천수의 1/3 초과시 해당없음)

    죄송합니다. 댓글 작성은 회원만 가능합니다.

    번호 제 목 이름 날짜 조회 추천
    913
    [방사능 주의] 오늘의 사시미 [14] 15/05/22 21:28 85 4
    912
    오유 중독된 아재들이 곧 겪을 현상 [1] 15/05/20 16:51 106 2
    911
    폰카 무보정 인생샷 [5] 15/05/18 22:11 65 5
    910
    산책로 15/05/12 23:46 22 2
    909
    윈도우 8.1 스토어에서 앱 설치 안되시는분! 15/03/28 11:51 64 0
    908
    하드 디스크 포맷 질문좀 해도 될까요 [4] 15/03/22 00:23 33 0
    906
    인게임 소리 안나는거 해결방법 아시는분 계신가요? [2] 15/01/05 21:25 41 0
    905
    jsp와 DB 연동 질문드립니다! [6] 14/12/10 09:46 45 0
    904
    오라클 blob 데이터 이미지 저장 질문입니다. [1] 14/12/02 14:22 35 0
    903
    html 화면 분할 질문좀 드릴게요 [4] 14/11/16 17:23 40 1
    엊그제 질문한 패널 문제 해결했습니당! + 질문 하나만 더 해도 될까요? 14/10/21 23:38 26 0
    901
    [본삭금]GUI 관련 질문 하나만 해도 될까요? [5] 14/10/20 01:39 31 0
    900
    매일 아가미로 호흡하다가 [4] 14/09/22 19:34 246 1
    899
    이것도 술게에 올려야 하는걸까요 [2] 14/09/14 01:58 34 2
    898
    [본삭금] 남대문 안경점 잘 아시는분 계신가요? 14/09/08 10:54 16 0
    897
    개토즈 발암... 14/09/07 12:06 41 0
    896
    이번시즌 250만개 모았는데.... [3] 14/09/01 01:04 36 1
    895
    맞춤법 질문좀 드릴게요 [6] 14/08/25 08:24 18 0
    894
    mc 충전 질문 드립니다. [4] 14/08/17 21:02 40 0
    893
    이거 엄청 흥한거 맞죠..? [2] 14/08/16 09:19 91 2
    892
    [병신백일장]우린 모두 똥을 싼다. [9] 14/08/13 20:46 21 1
    891
    음악좀 찾아 주실수 있을까요? [5] 14/07/27 22:54 25 1
    890
    자바 구구단 좀 도와주세용 [6] 14/07/10 12:04 34 0
    889
    남자가 여자보다 수명이 짧은 이유.youtube [1] 14/07/09 22:55 38 3
    888
    첫 해외 직구인데요 도와주실분 ㅜㅜ [2] 14/07/04 22:17 16 0
    887
    공지 떴습니다 (링크 有) [1] 14/06/29 04:09 56 0
    886
    운영자: 공지를 기다리게 만들어 미안하다!!!! [1] 14/06/29 03:49 141 0
    885
    이런 밤엔 야짤로 달려야죠!! [2] 14/06/29 03:07 63 1
    884
    운영진이 익명 못보게 하는 공지 몇번인지 아시는분 [2] 14/06/29 02:56 37 1
    [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [다음10개▶]
    단축키 운영진에게 바란다(삭제요청/제안) 운영게 게시판신청 자료창고 보류 개인정보취급방침 청소년보호정책 모바일홈