Skip to content

Commit

Permalink
Implement drag drop support for skins
Browse files Browse the repository at this point in the history
fix issue #85
  • Loading branch information
RoanH committed Dec 8, 2019
1 parent 8ca574c commit 3e65848
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions osuSkinChecker/src/me/roan/osuskinchecker/SkinChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.awt.dnd.DropTargetListener;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
Expand Down Expand Up @@ -418,6 +426,41 @@ public static void buildGUI(){
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);

new DropTarget(frame, new DropTargetListener(){

@Override
public void dragEnter(DropTargetDragEvent dtde){
}

@Override
public void dragOver(DropTargetDragEvent dtde){
}

@Override
public void dropActionChanged(DropTargetDragEvent dtde){
}

@Override
public void dragExit(DropTargetEvent dte){
}

@Override
public void drop(DropTargetDropEvent dtde){
if(dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)){
try{
dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
@SuppressWarnings("unchecked")
List<File> files = (List<File>)dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
if(files.size() > 0 && files.get(0).isDirectory()){
checkSkin(files.get(0));
}
}catch(UnsupportedFlavorException | IOException e){
//Pity, but not important
}
}
}
});
}

/**
Expand Down

0 comments on commit 3e65848

Please sign in to comment.