본문 바로가기
728x90

Development104

JTextField에 Tab키 Event 발생 JTextField에 Tab키 Event 발생 JTextField에서 Tab키를 이용할 경우 다음 컴포넌트로 이동한다. 로그인 창을 만들때 Tab키를 사용해 ID와 Password field를 이동하고자 할때는 즉, Tab키에 이벤트를 걸어 어떤 행동을 하고 싶은 경우 다음과 같이 처리한다. Component.setFocusTraversalKeysEnabled(boolean) 탭키를 이용하여 Component를 이동하고자 하면 true, 그렇지 않으면 false. //setFocusTraversalKeysEnabled(boolean) - 텍스트 필드에서 탭키를 이용해 이동을 할 것인지를 설정 사용예) JTextField idField = new JTextField(); JTextField pwdField.. 2019. 7. 9.
keyTyped(KeyEvent e) 메소드내에서의 KeyEvent.VK_BACK_SPACE 오류 관련. keyTyped(KeyEvent e) 메소드내에서의 KeyEvent.VK_BACK_SPACE 오류 관련. Key Event 발생시 아래와 같은 순서로 호출이 된다. Key Pressed(..) ▶ Key Typed(...) ▶ Key Released(..) 이때!!! 백스페이스키를 눌렀을 경우 각 메소드에서 인식하는 Key Code는 어떨까?? Key Pressed(..) : 8번. Key Typed(...) : 0번. 2019. 7. 9.
getClass().getResource("/data/head.dat") vs getClass().getResourceAsStream("/data/head.dat") getClass().getResource("/data/head.dat") vs getClass().getResourceAsStream("/data/head.dat") jar 파일에 묶여 있는 것이 아닌 디렉토리에서 파일을 읽을 경우. ▶ getClass().getResource("/data/head.dat") File file = new File(getClass().getResource("/data/head.dat").getPath()); BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); StringBuffer result = new StringBuffer(); String tmp = r.. 2019. 7. 9.
[Java] JTable 입력시 Cell의 값이 유실(?)되는 것을 막으려면? [Java] JTable 입력시 Cell의 값이 유실(?)되는 것을 막으려면? Java의 Swing 컴포넌트중 JTable의 Cell 값을 입력하는 도중 Table의 최종값을 DB 혹은 Repository에 저장하기 위한 액션으로 "OK"버튼을 클릭하여 JTable의 값을 취하고자 할때 Editing 중이던 Cell의 값을 얻지 못하는 에러가 발생한다. 이런 경우 어찌해야할까?? JTale의 clearSelection()... 등등의 명령을 사용해도 소용 없다. 이럴 경우 editCellAt(-1, -1) 명령을 먼저 내린 후 JTable의 값을 취하도록하면 문제 해결. 해당 작업은 try로 묶어준다. 아래와 같은 방식으로... try { ipcSetTable.editCellAt(-1, -1); } ca.. 2019. 7. 9.
728x90