카테고리 글 보관함: Java

Clipboard (copy, paste, cut) not working when dragging and dropping files in Swing

We’ll set the TransferHandler on the JTextArea to be a handler that can drag and drop files, which will overwrite the existing TransferHandler associated with the clipboard and make it disappear.

I couldn’t find a solution to this problem, even after hours of searching Stackoverflow, because it doesn’t happen unless the file is dropped into a JTextField or JTextArea.

This is where ChatGPT comes in as a savior.

I loved working with ChatGPT to find the answers.

Written in Korean.
https://chatgpt.com/share/8c34c15e-2d32-4c03-9ec0-f21ee0b6bd22

Below, the above is written in Korean.

JTextArea에 TransferHandler를 파일 드래그 앤 드롭이 가능한 핸들러로 설정하게 되는데 이렇게 하면 기존 클립보드와 연결된 TransferHandler가 덮어씌워져서 사라지게 된다.
JTextField나 JTextArea에 파일드롭을 하지 않으면 생기지 않은 문제여서 그런지 Stackoverflow를 몇시간 뒤져도 이 문제를 해결 할 방법이 없었다.
여기서 구세주 ChatGPT가 나타남.
ChatGPT와 함께 해답을 찾아가는 과정이 너무 좋았다.
https://chatgpt.com/share/8c34c15e-2d32-4c03-9ec0-f21ee0b6bd22

한글로 검색해서 들어올 사람은 없을것 같으니 DeepL로 번역한 영어로 씀.

이전에도 안풀리는 문제가 있어서 ChatGPT한테 물어보니 답은 아니어도 힌트를 얻어서 해결한 적이 있는데,
이번에는 ChatGPT가 해결 못하는 부분을 내가 힌트를 줘서 ChatGPT가 답을 찾는 장면이 나왔다.

이런건 구글 검색으로도 해결하지 못하는 문제라서 AI가 아주 인상적인 능력을 보여주는 것 같다.