MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / enableDragAndDrop

Method enableDragAndDrop

src/test/LoaderTest.java:165–192  ·  view source on GitHub ↗
(JTextArea jt)

Source from the content-addressed store, hash-verified

163 }
164
165 private void enableDragAndDrop(JTextArea jt){
166 DropTarget dropTarget=new DropTarget(jt,new DropTargetListener(){
167 public void dragEnter(DropTargetDragEvent e){}
168
169 public void dragExit(DropTargetEvent e){}
170
171 public void dragOver(DropTargetDragEvent e){}
172
173 public void dropActionChanged(DropTargetDragEvent e){}
174
175 public void drop(DropTargetDropEvent e){
176 try{
177 // Accept the drop first, important!
178 e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
179
180 // Get the files that are dropped as java.util.List
181 java.util.List list=(java.util.List) e.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
182
183 // Now get the first file from the list,
184 File file=(File)list.get(0);
185 String path=file.getAbsolutePath();
186 //jt.read(new FileReader(file),null);
187 loadIntoEditor(path);
188
189 }catch(Exception ex){}
190 }
191 });
192 }
193
194 private void openDnDResource(String target, String fileName) {
195 boolean loadFailed = false;

Callers 1

LoaderTestMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected