Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ScrollPane in netbeans GUI

 
samira samadi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,I'm using netbeans GUI,I am writing a program like paint program(in windows),I have a panel that I can paint on it,and also I can load image into this panel.
but the problem is that when I load an image,when it is bigger than my panel I can not see the hole image,I need to have something to let me edit all of the image,I used scroll Pane this way:
I added to my panel one scroll Pane,and then put another panel inside it,and wrote all of the functions of my first panel for this one.
now I can paint in this one,and I see the scrollbar,but when I use them things does not works well....and also when I load an image,still just one paart of it is seen and there is no scroll bars.

I would be so thankful if you help me.

 
Rob Spoor
Sheriff
Pie
Posts: 20531
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JScrollPane uses the preferred width of the component to determine when to show scroll bars, and how far these can scroll. Make sure the preferred size of the JPanel is correct; you can use setPreferredSize to set it.
 
samira samadi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you,I set the perefferedSize and Know I can see whole image well,but still I have one problem,when I begin painting on it,when I use scrollbars,last paintigs acts strangely!they get thicker or thinner,they would be shifted and ...
can you help me please?
 
samira samadi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you know when I use my panel's graphics to draw on it(:g.drawline()),when I use the scrollbar some previous paintings are lost....
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> you know when I use my panel's graphics to draw on it(:g.drawline()),when I use the scrollbar some previous paintings are lost....

expected behaviour if using
panel.getGraphics();
 
Rob Spoor
Sheriff
Pie
Posts: 20531
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should keep references to all custom painting, then redo them all in paintComponent -- after you've called super.paintComponent(g).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic