I can't figure out how to put scroll bar for my jrame or should I try to put inside of the jgraph? I tried different things but it either doesn't compile or doesn't show up or it covers the graph?
main java
final GraphMain applet=new GraphMain(file);
applet.init();
JFrame f=new JFrame("Title goes here");
f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
applet.stop();
applet.destroy();
System.exit(0);
}
});
f.setLayout(new BorderLayout());
f.add(applet, BorderLayout.CENTER);
f.setSize(DEFAULT_SIZE1);
applet.start();
f.setVisible(true);
jgraph extends JApplet
// create a JGraphT graph
UndirectedGraph<String, DefaultEdge> g =
new ListenableUndirectedGraph<String, DefaultEdge>( DefaultEdge.class );
// create a visualization using JGraph, via an adapter
m_jgAdapter = new JGraphModelAdapter<String, DefaultEdge>( g );
JGraph jgraph = new JGraph( m_jgAdapter );
adjustDisplaySettings( jgraph );
getContentPane( ).add( jgraph );
resize( DEFAULT_SIZE );
/* scrollbar = new Scrollbar(Scrollbar.HORIZONTAL, 50, 0, 0, 100);
add(scrollbar);*/
/* scrollbar = new Scrollbar(Scrollbar.HORIZONTAL, 50, 0, 0, 100);
add(scrollbar);
scrollbar.addAdjustmentListener(this);
*/
While I don't like the idea of creating and adding an applet to a JFrame, there are just so many things can go wrong...
Take a look at How to use ScrollPanes
getContentPane().add( new JScrollPane(jgrap));