code_junkie

JScrollPane now showing its viewport

Nov 13th, 2011
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. public class ContentPane extends JTabbedPane {
  2. private InfoPanel ip;
  3. ScrollPanel sp;
  4.  
  5. public InfoPanel getIp() {
  6. return ip;
  7. }
  8.  
  9. public ContentPane(GraphPanel gp) {
  10. this.sp = new ScrollPanel(gp);
  11. this.sp.setViewportView(gp);
  12.  
  13. this.addTab("Graph", this.sp);
  14. this.ip = new InfoPanel(gp);
  15. this.addTab("Info", ip);
  16. }
  17. }
  18.  
  19. public class ScrollPanel extends JScrollPane {
  20. public ScrollPanel(GraphPanel gp){
  21. this.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
  22. this.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  23. this.repaint();
  24. }
  25. }
  26.  
  27. public GraphPanel(StatusBar sb) {
  28. this.sb = sb;
  29. zoomLevel = 5;
  30. sm = new Simulation();
  31. mh = new MouseHandler(this, sm);
  32. this.addMouseListener(mh);
  33. this.setBackground(new Color(240, 165, 98));
  34. this.repaint();
  35. }
  36.  
  37. public class ScrollPanel extends JScrollPane {
  38. public ScrollPanel(GraphPanel gp){
  39.  
  40. // :::: HERE ::: you are not doing anything with gp
  41. // like this.setViewPort( gp ) or something like that
  42.  
  43. this.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
  44. this.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  45. this.repaint();
  46. }
  47. }
  48.  
  49. public class ScrollPanel extends JScrollPane {
  50. public ScrollPanel(GraphPanel gp){
  51. super( gp );
  52. .... etc ...
Add Comment
Please, Sign In to add comment