Files
swing-examples/Writerside2/topics/Drag-and-Drop.md
2024-06-12 13:10:10 +09:00

1.6 KiB

Drag & Drop

TransferHandler

  • component.setDragEnabled(boolean)
  • component.setDropMode(DropMode)
  • component.setTransferHandler(TransferHandler)

보내기

  • getSourceActions(JComponent) : 보내는 컴포넌트가 어떤 액션을 지원하는지.
  • createTransferable(JComponent) : 데이터를 묶어서 Transferable 객체로 만든다.
  • exportDone(JComponent,Transferable,int) : 내보내기가 완료된 이후에 호출된다.

받기

  • canImport(Transferable.TransferSupport) : 드래깅 동작 중 반복적으로 호출되며, 받는 컴퍼넌트가 드롭 동작을 지원하면 true를 반환한다.
  • importData(Transferable.TransferSupport) : 드롭 동작 후에 호출되며, 데이터 전송이 성공한 경우에는 true를 반환한다.

TransferSupport

  • getComponent()

  • getDropAction() : COPY | MOVE | LINK | COPY_OR_MOVE | NONE

  • getUserDropAction()

  • getSourceDropActions()

  • getDataFlavors()

  • isDataFlavorSupported(DataFlavor)

  • getTransferable()

  • getDropLocation()

  • setShowDropLocation(boolean)

DataFlavor

  • allHtmlFlavor
  • fragmentHtmlFlavor
  • imageFlavor
  • javFileListFlavor
  • javaJVMLocaleObjectMimeType
  • javaRemoteObjectMimeType
  • javaSerializedObjectMimeType
  • selectionHtmlFlavor
  • stringFlavor

DropLocation

  • JList.DropLocation
    • isInsert()
    • getIndex()
  • JTree.DropLocation
    • getChildIndex()
    • getPath()
  • JTable.DropLocation
    • isInsertRow()
    • isInserColumn()
    • getRow()
    • getColumn()
  • JTextComponent.DropLocation
    • getIndex()
    • getBias()