Drop target

Hi,

In my app I have two panels added to a tabbed pane with their respective documents and views.



I try dropping objects to my second panel, but they always end up in the first panel even though the first is not the topmost panel and is not even visible.



I combed through the code but could not figure out what needs changing.



Any suggestions on where to focus to try to debug this?



My app’s starting point was the Processor example from the sample code.



Thank you.

-Jo

I’ve built a very simple sample application that creates a JSplitPane. In the left pane I put a JGoPalette. In the right pane I put a JTabbedPane. In each tab, I place a separate JGoView. Everything seems to work correctly for me. It’s not too much code, so I’ll just provide it here:

import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import java.awt.*;
import java.awt.Rectangle;
import com.nwoods.jgo.*;
import com.nwoods.jgo.JGoView;

public class TestTabbedPanes {
private JFrame frame;
private final JSplitPane splitPane = new JSplitPane();
private final JGoPalette goPalette = new com.nwoods.jgo.JGoPalette();
private final JTabbedPane tabbedPane = new JTabbedPane();
private final JPanel panel = new JPanel();
private final JPanel panel_2 = new JPanel();
private final JGoView goView = new JGoView();
private final JGoView goView_1 = new JGoView();
/**
* Launch the application
* @param args
*/
public static void main(String args[]) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
TestTabbedPanes window = new TestTabbedPanes();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application
*/
public TestTabbedPanes() {
jbInit();
JGoBasicNode n = new JGoBasicNode("aaa");
goPalette.getDocument().add(n);

}
/**
* Initialize the contents of the frame
*/
private void jbInit() {
frame = new JFrame();
frame.setBounds(100, 100, 624, 375);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.getContentPane().add(splitPane, BorderLayout.CENTER);
splitPane.setDividerLocation(150);

splitPane.setLeftComponent(goPalette);
goPalette.setBounds(0, 0, 165, 322);

splitPane.setRightComponent(tabbedPane);

tabbedPane.addTab("Tab 1", null, panel, null);
panel.setLayout(new BorderLayout());

panel.add(goView, BorderLayout.CENTER);

tabbedPane.addTab("Tab 2", null, panel_2, null);
panel_2.setLayout(new BorderLayout());

panel_2.add(goView_1, BorderLayout.CENTER);
}
}

Thanks for the sample. It definitely works on my machine.

However, in my main app I am not sure where to start looking for the problem.

I’m using Netbeans to develop my app.

The code is a little big to send all of it, but I will try to create a smaller version that I can send.

Since it is going to be Netbeans platform dependent I wonder if you will be able to take a look. I will try to see if I can create the issue with just the standard swing components.

If on the other hand you can suggest some things to look for I can try to figure it out myself.

Here is some more info:

I have a project panel that is instantiated for each new project. Each instance
of the panel has a new view and a new document. I am using Drag and Drop
to drop a String object onto the view.
As in the Processor example, I am using AppAction to create various actions.
So, the “Processor” class in the example is equivalent to a project for
me.
I have these AppActions instantiated for each project object.
I have a feeling that it is somewhere in there that I lose the reference to my document/view.

Much appreciate the help.
-Jo

Problem solved …

I hadn’t looked closely how the AppAction class from the Processor example worked.

The AppAction class was acting on the wrong project.