diff --git a/osuSkinChecker/src/me/roan/osuskinchecker/SkinChecker.java b/osuSkinChecker/src/me/roan/osuskinchecker/SkinChecker.java index 43dc337..1bda22f 100644 --- a/osuSkinChecker/src/me/roan/osuskinchecker/SkinChecker.java +++ b/osuSkinChecker/src/me/roan/osuskinchecker/SkinChecker.java @@ -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; @@ -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 files = (List)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 + } + } + } + }); } /**