List of usage examples for java.awt.dnd DnDConstants ACTION_COPY
int ACTION_COPY
To view the source code for java.awt.dnd DnDConstants ACTION_COPY.
Click Source Link
From source file:se.trixon.solos.core.panel.NavigatorPanel.java
private void init() { DropTarget dropTarget = new DropTarget() { @Override//from w ww . j av a 2 s .c o m public synchronized void drop(DropTargetDropEvent evt) { try { evt.acceptDrop(DnDConstants.ACTION_COPY); List<File> droppedFiles = (List<File>) evt.getTransferable() .getTransferData(DataFlavor.javaFileListFlavor); File file = droppedFiles.get(0); if (droppedFiles.size() == 1) { if (file.isDirectory()) { setPath(file); } else if (file.isFile()) { setPath(file.getParentFile()); } } else { setPath(file.getParentFile()); } directoryChanged(); } catch (UnsupportedFlavorException | IOException ex) { } } }; textField.setDropTarget(dropTarget); }
From source file:se.trixon.toolbox.geotagger.GeotaggerTopComponent.java
private void init() { openButton.setIcon(Pict.Actions.DOCUMENT_OPEN.get(TOOLBAR_ICON_SIZE)); editToggleButton.setIcon(Pict.Actions.DOCUMENT_EDIT.get(TOOLBAR_ICON_SIZE)); closeButton.setIcon(Pict.Actions.WINDOW_CLOSE.get(TOOLBAR_ICON_SIZE)); closeButton.setEnabled(false);/*from w w w . j av a2s .c om*/ startButton.setIcon(Pict.Actions.ARROW_RIGHT.get(ICON_SIZE)); startButton.setToolTipText(Dict.START.getString()); startButton.setEnabled(false); saveLogButton.setIcon(Pict.Actions.DOCUMENT_SAVE.get(ICON_SIZE)); saveLogButton.setEnabled(false); helpButton.setIcon(Pict.Actions.HELP_CONTENTS.get(ICON_SIZE)); helpButton.setToolTipText(Dict.HELP.getString()); DropTarget dropTarget = new DropTarget() { @Override public synchronized void drop(DropTargetDropEvent evt) { try { evt.acceptDrop(DnDConstants.ACTION_COPY); List<File> droppedFiles = (List<File>) evt.getTransferable() .getTransferData(DataFlavor.javaFileListFlavor); if (droppedFiles.get(0).isFile()) { openFile(droppedFiles.get(0)); } } catch (UnsupportedFlavorException | IOException ex) { } } }; scrollPane.setDropTarget(dropTarget); mTableModel = new GeotagTableModel(); table.setModel(mTableModel); mTableRowSorter = new TableRowSorter<>(mTableModel); table.setRowSorter(mTableRowSorter); TableColumnModel columnModel = table.getColumnModel(); NumericTableCellRenderer cooNumericTableCellRenderer = new NumericTableCellRenderer(Double.class, 6); NumericTableCellRenderer altNumericTableCellRenderer = new NumericTableCellRenderer(Double.class, 4); columnModel.getColumn(GeotagTableModel.COLUMN_LATITUDE).setCellRenderer(cooNumericTableCellRenderer); columnModel.getColumn(GeotagTableModel.COLUMN_LONGITUDE).setCellRenderer(cooNumericTableCellRenderer); columnModel.getColumn(GeotagTableModel.COLUMN_ALTITUDE).setCellRenderer(altNumericTableCellRenderer); columnModel.getColumn(GeotagTableModel.COLUMN_NAME).setPreferredWidth(200); columnModel.getColumn(GeotagTableModel.COLUMN_LATITUDE).setPreferredWidth(100); columnModel.getColumn(GeotagTableModel.COLUMN_LONGITUDE).setPreferredWidth(100); columnModel.getColumn(GeotagTableModel.COLUMN_ALTITUDE).setPreferredWidth(50); }
From source file:unikn.dbis.univis.explorer.VExplorer.java
License:asdf
private void initDragAndDrop() { DragSource dragSource = DragSource.getDefaultDragSource(); dragSource.addDragSourceListener(tree); dragSource.createDefaultDragGestureRecognizer(tree, DnDConstants.ACTION_COPY, tree); }
From source file:unikn.dbis.univis.visualization.graph.VGraph.java
/** * Creates a new VGraph with drop target action and a * tree layout cache.//from w w w. j a va 2 s . c o m */ public VGraph() { setUI(new VGraphUI()); setDropTarget(new DropTarget(this, DnDConstants.ACTION_COPY, new VGraphDropTargetListener())); setModel(model); setGraphLayoutCache(cache); setEditable(false); setMoveable(false); setSelectionEnabled(true); layout.setOrientation(SwingConstants.NORTH); }
From source file:view.MainWindow.java
private void setupDropListener() { this.setDropTarget(new DropTarget() { @Override//from w w w . ja va 2 s . c om public synchronized void drop(DropTargetDropEvent evt) { try { evt.acceptDrop(DnDConstants.ACTION_COPY); List<File> droppedFiles = (List<File>) evt.getTransferable() .getTransferData(DataFlavor.javaFileListFlavor); if (!droppedFiles.isEmpty()) { for (File file : droppedFiles) { if (file.exists() && file.isFile() && file.getAbsolutePath().endsWith(".pdf")) { if (loadPdf(file, false)) { ctrl.openDocument(file.getAbsolutePath()); workspacePanel.setDocument(ctrl.getDocument()); } else { errorList.add(file.getAbsolutePath()); } } else if (file.exists() && file.isDirectory()) { loadFolder(file, true); } } showErrors(); } } catch (UnsupportedFlavorException | IOException ex) { controller.Logger.getLogger().addEntry(ex); } } }); }