• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ScrollPane in netbeans GUI

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic