본문으로 건너뛰기
Elmi Tech Note Logo light Elmi Tech Note Logo dark Elmi Tech Note

마비노기 모바일 해외 접속 & 윈도우 난민을 위한 리눅스 가이드

Elmi Tech Note Logo light Elmi Tech Note Logo dark Elmi Tech Note

마비노기 모바일 해외 접속 & 윈도우 난민을 위한 리눅스 가이드

  • 홈
  • 🔰먼저 여기부터 클릭! [정리글] 해외에서 마비노기 모바일 VPN 접속
  • 홈
  • 🔰먼저 여기부터 클릭! [정리글] 해외에서 마비노기 모바일 VPN 접속
닫기

검색

Java

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

By 엘미타
2024년 05월 31일 1 Min Read
0

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
    private class CustomTransferHandler extends TransferHandler {
        private final TransferHandler originalHandler;
 
    public CustomTransferHandler(TransferHandler originalHandler) {
        this.originalHandler = originalHandler;
    }
 
    @Override
    public boolean canImport(TransferSupport support) {
        if (support.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
            return true;
        }
        return originalHandler != null && originalHandler.canImport(support);
    }
 
    @Override
    public boolean importData(TransferSupport support) {
        if (support.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
            try {
                List<File> files = (List<File>) support.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
                for (File file : files) {
                    textArea.append(file.getAbsolutePath() + "\n");
                }
                return true;
            } catch (UnsupportedFlavorException | IOException ex) {
                ex.printStackTrace();
            }
            return false;
        } else if (originalHandler != null) {
            return originalHandler.importData(support);
        }
        return false;
    }
 
    @Override
    protected void exportToClipboard(JComponent comp, Clipboard clipboard, int action) {
        if (originalHandler != null) {
            originalHandler.exportToClipboard(comp, clipboard, action);
        }
    }

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가 아주 인상적인 능력을 보여주는 것 같다.

Tags:

문제 해결JavaSwing
작성자

엘미타

일본에서 일하고 있는 자바 웹 어플리케이션 개발자.

Follow Me
다른 기사
Previous

우분투 데스크탑은 아직 못 써먹겠다.

Next

Dell Inspiron 7472 윈도우11에서 업데이트 후, 터치패드 사용 불가 문제

댓글이 없어요! 첫 댓글을 남겨보세요.

답글 남기기 응답 취소

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

인기 글

이 카테고리에 속한 글

Java
  • Clipboard (copy, paste, cut) not working when dragging and dropping files in Swing 2024년 05월 31일

최신 글

  • [칼럼] 리눅스 입문자에게 CachyOS(캐시OS)를 추천하는 이유
  • [칼럼] 구글 SEO가 망치고 있는 인터넷 생태계: 일본의 오늘과 한국의 내일
  • Cachyos, Niri, Noctalia 입문 가이드. 설치 후 설정할 것들
  • [CachyOS] 리눅스에서 명일방주 엔드필드 실행하는 방법
  • 오라클 클라우드 이메일 전송 서비스 설정 방법

최신 댓글

  • 국 - 버츄얼 박스에 OpenWrt with 미꾸라지 설치
  • 엘미타 - [모비노기] 일퀘/주간퀘 체크 사이트 오픈
  • 엘미타 - [모비노기] 일퀘/주간퀘 체크 사이트 오픈
  • 익명 - [모비노기] 일퀘/주간퀘 체크 사이트 오픈
  • 익명 - [모비노기] 일퀘/주간퀘 체크 사이트 오픈

카테고리

태그

0x80bd0009 Arch Linux Endeavouros geoip github Go 언어 gui Java KDE Plasma kodi nginx Niri Noctalia Ollama OpenWrt sciter smb Stable Diffusion Swing Troubleshooting wireguard Xbox series x 건틀릿 공유기 루트리스 룬테라 리눅스 게이밍 리눅스 배포판 마비노기 모바일 마인크래프트 명일방주 엔드필드 모바일 게임 사이버 펑크 2077 오즈 리라이트 우분투 데스크탑 24.04 LTS 우분투 서버 20.04 LTS 우분투 서버 22.04 LTS 우분투 서버 24.04 LTS 윈도우11 윈도우 11 칼럼 컵히어로즈 톰캣9 포로덱 프로톤

Copyright 2026 — Elmi Tech Note. All rights reserved. Blogsy WordPress Theme