I have a class :public class GraphEditorPane extends JGraph
and I am using this "GraphEditorPane" as follows :
public JScrollPane getGraphPaneScrollPane() {
if (graphPaneScrollPane == null) {
graphPaneScrollPane = new JScrollPane();
//graphPaneScrollPane.setViewportView(getGraphEditorPane());
graphPaneScrollPane.setViewportView(getGraphEditorPane());
}
return graphPaneScrollPane;
}
public GraphEditorPane getGraphEditorPane() {
graphEditorPane = new GraphEditorPane(); }
I am using this 'GraphEditorPane' to draw a Graph over it. Now my question is -- Is there any way that I can convert this JGraph into a Glass Pane so that my 'GraphEditorPane' would be transparent and I could still draw over it ?
I think you're over complicating things.
The glass pane will be the top most component (when visible), painting over the top of everything else. If you simply want to "overlay" one component over another you there are much simpler solutions...
The simplest idea I can think off would be to use a
JLayeredPane
, setting it up to use aGridBagLayout
so you don't need to worry about positioning the child components. This will give you quick and easy methods for changing the order of components.Another solution would be to simply add the overlay component directly on top of the underlay component.