-
Bug
-
Resolution: Fixed
-
P1
-
1.2.0, 1.3.0
-
kestrel
-
generic, x86, sparc
-
generic, solaris_7, windows_95, windows_98, windows_nt
-
Verified
jdk1.3-M Drag-N-Drop works for dragging text from an external application
such as Solaris TextEditor or Window's WordPad and dropping it into the
Java application, but not the other way around.
The following sample code demonstrate the problem.
Roger 11/2/99
import java.io.*;
import java.awt.*;
import java.awt.dnd.*;
import java.awt.event.*;
import java.awt.datatransfer.*;
public class dnd extends Frame {
public static void main(String argv[]) {
dnd test = new dnd();
}
dnd () {
String textToBeDropped =
"\n" +
"\tJava, Java, Java.\n\n";
Panel workPanel = new Panel(new BorderLayout());
Label dragComponent =
new Label(" Drag Me and drop an editor ", Label.CENTER);
dragComponent.setBackground(Color.pink);
dragComponent.setFont(new Font("Courier", Font.BOLD, 32));
workPanel.add(dragComponent, BorderLayout.NORTH);
TextArea droppedText =
new TextArea(textToBeDropped, 4, 42, TextArea.SCROLLBARS_NONE);
droppedText.setEditable(false);
droppedText.setBackground(Color.white);
droppedText.setFont(new Font("Courier", Font.PLAIN, 14));
workPanel.add(droppedText, BorderLayout.CENTER);
add(workPanel); // Add test panel to frame
DnDTest3 dnd =
new DnDTest3(dragComponent, textToBeDropped);
DragGestureRecognizer recognizer=DragSource.getDefaultDragSource().
createDefaultDragGestureRecognizer(dragComponent,
DnDConstants.ACTION_COPY, dnd);
setSize(600, 400);
setVisible(true);
}
}
class ComponentTransferable3 implements Transferable {
String text = "";
DataFlavor possibleFlavors[] = {
new DataFlavor
("text/plain; class=java.io.InputStream; charset=iso8859-1",
"Latin based language"),
new DataFlavor
("text/plain; class=java.io.InputStream; charset=ascii",
"plain ASCII"),
new DataFlavor
("text/enhanced; class=java.io.InputStream; charset=ascii",
"enhanced ASCII"),
new DataFlavor
("text/plain; class=java.io.InputStream; charset=unknown",
"other ISO standards"),
// new DataFlavor
// ("text/plain; class=java.io.InputStream; charset=unicode",
// "Java Unicode")
};
ByteArrayInputStream inputS = null;
public ComponentTransferable3 (String text) {
this.text = text;
byte[] bytes = text.getBytes();
inputS = new ByteArrayInputStream(bytes);
}
public DataFlavor[] getTransferDataFlavors() {
return possibleFlavors;
}
public boolean isDataFlavorSupported(DataFlavor flavor) {
return true;
}
public Object getTransferData(DataFlavor flavor) {
return inputS;
}
}
class DnDTest3 implements DragGestureListener {
String textToBeDropped = "The text to be dragged";
public Label dragComponent;
public DnDTest3(Label dragComponent,
String textToBeDropped) {
this.dragComponent = dragComponent;
this.textToBeDropped = textToBeDropped;
}
public void dragGestureRecognized(DragGestureEvent e) {
ComponentTransferable3 myTransferable =
new ComponentTransferable3(textToBeDropped);
e.startDrag(DragSource.DefaultCopyDrop, myTransferable,
new DragSourceListener() {
public void dragEnter(DragSourceDragEvent dsde) {}
public void dragOver(DragSourceDragEvent dsde) {}
public void dropActionChanged(DragSourceDragEvent dsde) {}
public void dragExit(DragSourceEvent dse) {}
public void dragDropEnd(DragSourceDropEvent dsde) {}
});
}
}
such as Solaris TextEditor or Window's WordPad and dropping it into the
Java application, but not the other way around.
The following sample code demonstrate the problem.
Roger 11/2/99
import java.io.*;
import java.awt.*;
import java.awt.dnd.*;
import java.awt.event.*;
import java.awt.datatransfer.*;
public class dnd extends Frame {
public static void main(String argv[]) {
dnd test = new dnd();
}
dnd () {
String textToBeDropped =
"\n" +
"\tJava, Java, Java.\n\n";
Panel workPanel = new Panel(new BorderLayout());
Label dragComponent =
new Label(" Drag Me and drop an editor ", Label.CENTER);
dragComponent.setBackground(Color.pink);
dragComponent.setFont(new Font("Courier", Font.BOLD, 32));
workPanel.add(dragComponent, BorderLayout.NORTH);
TextArea droppedText =
new TextArea(textToBeDropped, 4, 42, TextArea.SCROLLBARS_NONE);
droppedText.setEditable(false);
droppedText.setBackground(Color.white);
droppedText.setFont(new Font("Courier", Font.PLAIN, 14));
workPanel.add(droppedText, BorderLayout.CENTER);
add(workPanel); // Add test panel to frame
DnDTest3 dnd =
new DnDTest3(dragComponent, textToBeDropped);
DragGestureRecognizer recognizer=DragSource.getDefaultDragSource().
createDefaultDragGestureRecognizer(dragComponent,
DnDConstants.ACTION_COPY, dnd);
setSize(600, 400);
setVisible(true);
}
}
class ComponentTransferable3 implements Transferable {
String text = "";
DataFlavor possibleFlavors[] = {
new DataFlavor
("text/plain; class=java.io.InputStream; charset=iso8859-1",
"Latin based language"),
new DataFlavor
("text/plain; class=java.io.InputStream; charset=ascii",
"plain ASCII"),
new DataFlavor
("text/enhanced; class=java.io.InputStream; charset=ascii",
"enhanced ASCII"),
new DataFlavor
("text/plain; class=java.io.InputStream; charset=unknown",
"other ISO standards"),
// new DataFlavor
// ("text/plain; class=java.io.InputStream; charset=unicode",
// "Java Unicode")
};
ByteArrayInputStream inputS = null;
public ComponentTransferable3 (String text) {
this.text = text;
byte[] bytes = text.getBytes();
inputS = new ByteArrayInputStream(bytes);
}
public DataFlavor[] getTransferDataFlavors() {
return possibleFlavors;
}
public boolean isDataFlavorSupported(DataFlavor flavor) {
return true;
}
public Object getTransferData(DataFlavor flavor) {
return inputS;
}
}
class DnDTest3 implements DragGestureListener {
String textToBeDropped = "The text to be dragged";
public Label dragComponent;
public DnDTest3(Label dragComponent,
String textToBeDropped) {
this.dragComponent = dragComponent;
this.textToBeDropped = textToBeDropped;
}
public void dragGestureRecognized(DragGestureEvent e) {
ComponentTransferable3 myTransferable =
new ComponentTransferable3(textToBeDropped);
e.startDrag(DragSource.DefaultCopyDrop, myTransferable,
new DragSourceListener() {
public void dragEnter(DragSourceDragEvent dsde) {}
public void dragOver(DragSourceDragEvent dsde) {}
public void dropActionChanged(DragSourceDragEvent dsde) {}
public void dragExit(DragSourceEvent dse) {}
public void dragDropEnd(DragSourceDropEvent dsde) {}
});
}
}
- duplicates
-
JDK-4217422 App freezes on windows during move operation
-
- Closed
-
-
JDK-4281886 Drag and drop into textedit does not work.
-
- Closed
-
-
JDK-4216100 Drag and Drop using Java Plugin hangs VM
-
- Closed
-
-
JDK-4216890 Swing drag and drop deadlock
-
- Closed
-
-
JDK-4253406 Kestrel-K:DnD of text from JVM to wordpad does not work on Win NT
-
- Closed
-
- relates to
-
JDK-4291756 1.3FCS_O:Dragging text from an external application to Java application FAILED
-
- Closed
-
(1 relates to)