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();
}