Search code examples
graphjungscrollbarsjung2

GraphZoomScrollPane doesn't render content


I use JUNG framework to build my Semantic Tree and I have a big problem cause my Tree is very large and i need and scroll bars. I've found somewhere that GraphZoomScrollPane is the best option to do this, but when i try to render my graph using this class the content doesnt render.

When I set JPanel with VisualizationViewer object everything works fine but when I wrap VisualizationViewer in GraphZoomScrollPane and then set JPanel with wrapper it doesn't work.

Layout layout = new TreeLayout(ftb.getGraph());
server = new VisualizationViewer<String, FinalTreeNode>(
Panel panel=server;

It works and I see my graph in JPanel.

Layout layout = new TreeLayout(ftb.getGraph());
server = new VisualizationViewer<String, FinalTreeNode>(layout);
GraphZoomScrollPane gzsp = new GraphZoomScrollPane(server);
Panel panel =  gzsp;

It doesn't work. I don't see my graph and scrollbras.

Thera are no Exceptions. Can abody help me ? Because I've tried almost everything and it doesn't work. I'm runnig out of time.


Solution

  • Why not adding the GraphZoomScrollPane as a component inside your JPanel?

    panel = new JPanel(new BorderLayout());
    panel.add(gzsp, BorderLayout.CENTER);
    panel.updateUI();