use of java.awt.datatransfer.DataFlavor in project JMRI by JMRI.
the class EditPortalFrame method makeDndIconPanel.
/**
* ******************** DnD ****************************
*/
protected JPanel makeDndIconPanel() {
_dndPanel = new JPanel();
String fileName = "resources/icons/throttles/RoundRedCircle20.png";
NamedIcon icon = new NamedIcon(fileName, fileName);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), Bundle.getMessage("BeanNamePortal")));
try {
JLabel label = new IconDragJLabel(new DataFlavor(Editor.POSITIONABLE_FLAVOR));
label.setIcon(icon);
label.setName(Bundle.getMessage("BeanNamePortal"));
panel.add(label);
} catch (java.lang.ClassNotFoundException cnfe) {
cnfe.printStackTrace();
}
_dndPanel.add(panel);
return _dndPanel;
}
use of java.awt.datatransfer.DataFlavor in project JMRI by JMRI.
the class ReporterItemPanel method makeDndIconPanel.
@Override
protected void makeDndIconPanel(HashMap<String, NamedIcon> iconMap, String displayKey) {
if (_update) {
return;
}
_reporter = new ReporterIcon(_editor);
JPanel panel = new JPanel();
JPanel comp;
try {
comp = getDragger(new DataFlavor(Editor.POSITIONABLE_FLAVOR));
comp.setToolTipText(Bundle.getMessage("ToolTipDragIcon"));
} catch (java.lang.ClassNotFoundException cnfe) {
cnfe.printStackTrace();
comp = new JPanel();
}
panel.add(comp);
panel.revalidate();
int width = Math.max(100, panel.getPreferredSize().width);
panel.setPreferredSize(new java.awt.Dimension(width, panel.getPreferredSize().height));
panel.setToolTipText(Bundle.getMessage("ToolTipDragIcon"));
_dragIconPanel = panel;
_dragIconPanel.setToolTipText(Bundle.getMessage("ToolTipDragIcon"));
}
use of java.awt.datatransfer.DataFlavor in project jdk8u_jdk by JetBrains.
the class DataFlavorComparatorTest method main.
public static void main(String[] args) {
DataTransferer.DataFlavorComparator comparator = new DataTransferer.DataFlavorComparator();
DataFlavor flavor1 = DataFlavor.imageFlavor;
DataFlavor flavor2 = DataFlavor.selectionHtmlFlavor;
if (comparator.compare(flavor1, flavor2) == 0) {
throw new RuntimeException(flavor1.getMimeType() + " and " + flavor2.getMimeType() + " should not be equal");
}
}
use of java.awt.datatransfer.DataFlavor in project jdk8u_jdk by JetBrains.
the class DataFlavorComparatorTest1 method main.
public static void main(String[] args) throws Exception {
String[] mimes = new String[] { "text/plain;class=java.nio.ByteBuffer;charset=UTF-8", "text/uri-list;class=java.nio.ByteBuffer;charset=UTF-8", "text/plain;class=java.nio.ByteBuffer;charset=UTF-16LE", "text/uri-list;class=java.nio.ByteBuffer;charset=UTF-16LE", "application/x-java-text-encoding", "application/x-java-serialized-object;class=java.lang.String", "text/plain;class=java.io.InputStream;charset=UTF-8", "text/uri-list;class=java.io.InputStream;charset=UTF-8", "text/plain;class=java.io.InputStream;charset=windows-1252", "text/uri-list;class=java.io.InputStream;charset=windows-1252", "application/x-java-url;class=java.net.URL", "text/plain;class=java.io.Reader", "text/plain;charset=windows-1252", "text/uri-list;class=java.io.Reader", "text/uri-list;charset=windows-1252", "text/plain;charset=UTF-8", "text/uri-list;charset=UTF-8", "text/plain;class=java.io.InputStream;charset=US-ASCII", "text/uri-list;class=java.io.InputStream;charset=US-ASCII", "text/plain;class=java.io.InputStream;charset=UTF-16LE", "text/plain;charset=US-ASCII", "text/uri-list;class=java.io.InputStream;charset=UTF-16LE", "text/uri-list;charset=US-ASCII", "text/plain;charset=UTF-16LE", "text/uri-list;charset=UTF-16LE", "text/plain;class=java.nio.ByteBuffer;charset=UTF-16BE", "text/uri-list;class=java.nio.ByteBuffer;charset=UTF-16BE", "text/plain;class=java.nio.ByteBuffer;charset=ISO-8859-1", "text/uri-list;class=java.nio.ByteBuffer;charset=ISO-8859-1", "text/plain", "text/uri-list", "text/plain;class=java.nio.ByteBuffer;charset=UTF-16", "text/uri-list;class=java.nio.ByteBuffer;charset=UTF-16", "text/plain;class=java.io.InputStream;charset=unicode", "text/uri-list;class=java.io.InputStream;charset=UTF-16", "text/plain;class=java.nio.CharBuffer", "text/uri-list;class=java.nio.CharBuffer", "text/plain;class=java.lang.String", "text/plain;charset=UTF-16BE", "text/uri-list;class=java.lang.String", "text/uri-list;charset=UTF-16BE", "text/plain;charset=ISO-8859-1", "text/uri-list;charset=ISO-8859-1", "text/plain;class=java.io.InputStream;charset=UTF-16BE", "text/uri-list;class=java.io.InputStream;charset=UTF-16BE", "text/plain;class=java.nio.ByteBuffer;charset=US-ASCII", "text/uri-list;class=java.nio.ByteBuffer;charset=US-ASCII", "text/plain;class=java.io.InputStream;charset=ISO-8859-1", "text/uri-list;class=java.io.InputStream;charset=ISO-8859-1", "text/plain;charset=UTF-16", "text/plain;class=java.nio.ByteBuffer;charset=windows-1252", "text/uri-list;charset=UTF-16", "text/uri-list;class=java.nio.ByteBuffer;charset=windows-1252", "text/plain;class=java.io.InputStream;charset=windows-1252", "text/uri-list;class=java.io.InputStream;charset=windows-1252" };
DataFlavor[] flavors = new DataFlavor[mimes.length];
for (int i = 0; i < flavors.length; i++) {
flavors[i] = new DataFlavor(mimes[i]);
}
testComparator(new DataTransferer.DataFlavorComparator(true), flavors);
testComparator(new DataTransferer.DataFlavorComparator(false), flavors);
}
use of java.awt.datatransfer.DataFlavor in project SAGU by brianmcmichael.
the class FileDrop method isDragOk.
// end dropListener
/**
* Determine if the dragged data is a file list.
*/
private boolean isDragOk(final java.io.PrintStream out, final java.awt.dnd.DropTargetDragEvent evt) {
boolean ok = false;
// Get data flavors being dragged
java.awt.datatransfer.DataFlavor[] flavors = evt.getCurrentDataFlavors();
// See if any of the flavors are a file list
int i = 0;
while (!ok && i < flavors.length) {
// BEGIN 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added.
// Is the flavor a file list?
final DataFlavor curFlavor = flavors[i];
if (curFlavor.equals(java.awt.datatransfer.DataFlavor.javaFileListFlavor) || curFlavor.isRepresentationClassReader()) {
ok = true;
}
// END 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added.
i++;
}
// If logging is enabled, show data flavors
if (out != null) {
if (flavors.length == 0)
log(out, "FileDrop: no data flavors.");
for (i = 0; i < flavors.length; i++) log(out, flavors[i].toString());
}
return ok;
}
Aggregations