Meaningless Drivel is fun!*
The moose likes Swing / AWT / SWT and the fly likes ScrollPane in netbeans GUI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "ScrollPane in netbeans GUI" Watch "ScrollPane in netbeans GUI" New topic
Author

ScrollPane in netbeans GUI

samira samadi
Greenhorn

Joined: Jul 06, 2010
Posts: 9
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

Joined: Oct 27, 2005
Posts: 19653
    
  18

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
samira samadi
Greenhorn

Joined: Jul 06, 2010
Posts: 9
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

Joined: Jul 06, 2010
Posts: 9
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

Joined: Jun 09, 2003
Posts: 4632
> 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

Joined: Oct 27, 2005
Posts: 19653
    
  18

You should keep references to all custom painting, then redo them all in paintComponent -- after you've called super.paintComponent(g).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ScrollPane in netbeans GUI
 
Similar Threads
How to scroll an image ?
Problem in printing a JTable
New Image in JScrollPane
Which JScrollPane ?
Is there any way to bring the a Vertical Scroll Bars of the Scroll Pane at the Bottom by default???