This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
    Bookmark Topic Watch Topic
  • New Topic

graph

 
shalini gnana
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Report post to moderator
can anyone say me how to draw a graph by getting x,y co-ordinates(not by calculating the co-ordinates) in applet with scrollpane.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Report post to moderator
You will have to get yourself a Component you can actually draw on. You can't draw on a JScrollPane, but you can put something like a JPanel on it. You can draw on a JPanel with the usual methods, paintComponent() and Graphics.drawPolyLine().
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
Override getPreferredSize() to return the size you want so it will scroll, because otherwise it will never scroll without any components on it.

Basically returning the most bottom-right point of the drawing would be good.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please don't ask the same question twice.
 
    Bookmark Topic Watch Topic
  • New Topic