Drag Drop from JGoPalette to JGoView isn't worki

Hi,

I have a Charting Applet that has recently been modified to include an overview and a palette. formerly it only had a view. The drag & Drop from the palette to the view fails; specifically, selecting a palette element works fine, but the drag & drop onto the view pane fails.

How do I make drag & drop work? I am using Java 1.4.2_05 and 1.5.0_09 and also 1.6.1_01 and it fails in all three

Here’s the relevant pieces of code.

In the Constructor

Note: ChartView is a subclass of JGoView, it has some code for zooming

public class ChartView extends JGoView { … }

public ChartingApplet() {
// Create the main graphics window
_myView = new ChartView(this);
_myDoc = _myView.getDocument();
_myView.setInternalMouseActions(DnDConstants.ACTION_MOVE);

    // new code (phils)
    _mySplitPaneMain = new JSplitPane();
    _mySplitPaneLeft = new JSplitPane();
    _myOverview = new JGoOverview();
    _myPalette = new JGoPalette();

    // default stuff
    _titlePanel = buildTitlePanel();
    setTitleWaiting();
    setJMenuBar(new JMenuBar());

    // new code (phils) - set up frames (split panes) for applet display
    _mySplitPaneLeft.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    _mySplitPaneLeft.setTopComponent(_myOverview);
    _mySplitPaneLeft.setRightComponent(_myPalette);
    _mySplitPaneMain.setLeftComponent(_mySplitPaneLeft);
    _mySplitPaneMain.setRightComponent(_myView);

    // new code (phils) - set up relationship between Overview and ChartView
    _myOverview.setObserved(_myView);

    Container contentPane = getContentPane();
    
    _mySplitPaneLeft.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    _myOverview.setObserved(_myView);
    _mySplitPaneLeft.setTopComponent(_myOverview);

    _myPalette.setShowSampleItems(true);
    _mySplitPaneLeft.setRightComponent(_myPalette);

    _mySplitPaneMain.setLeftComponent(_mySplitPaneLeft);

    _mySplitPaneMain.setRightComponent(_myView);

    getContentPane().add(_mySplitPaneMain, java.awt.BorderLayout.CENTER);
    contentPane.validate();

}

and in the JApplet.start

public void start() {
    // enable drag-and-drop from separate thread
    //new Thread(this).start();
    _myView.initializeDragDropHandling();
}

You need to call JGoView.initializeDragDropHandling() from a separate thread, as the examples show:

public void start() { // Applet starting
new Thread(this).start(); // enable drag-and-drop from separate thread (JDC bug 4225247)
}
public void run() {
myView.initializeDragDropHandling();
}

OK, I tried it and it still fails.

public class ChartingApplet extends JApplet implements Runnable {

public void start() {
    // enable drag-and-drop from separate thread
    new Thread(this).start();
}

public void run() {
    _myView.initializeDragDropHandling();
}


}

By the way, I am using JGo 5.0

Did you also call initializeDragDropHandling on your JGoPalette component?

You also need to clear Java's cache of JARs -- I tripped across this problem when I tried changing an existing applet. Make sure that the applet really is a new one, and not an old one.

OK It works now, The change was as follows [I am including the code here so that other forum users can see it and avoid asking the same question again]

public class ChartingApplet extends JApplet implements Runnable {

public void start() {
// enable drag-and-drop from separate thread
new Thread(this).start();
}

public void run() {
_myView.initializeDragDropHandling();
_myPalette.initializeDragDropHandling();
}


private JGoView _myView;
private JGoPalette _myPalette;


}