Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

JScrollPane

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my application
JFrame holdes JScrollPane called P1 .JFrame have BorderLayout .
P1 Scrollpane holdes Jpanel P2
Panel P2 holdes image .
When i add zoom effect to image ,that time panel should get Scroll bar but it doesn't showing it.

class showZoomImage extends JPanel
{
Image img;
public void paint(Graphics g){
this.setPreferredSize(img.getWidth(),img.getHeight());
g.drawImage(img,width, height,this);
}
}
 
Manoj Tare
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
The knob disappears .
If JPanel is larger than the preferredSize of the ScrollPane although it not shwing knob (Slider)
Pls give some tips on this .
I would be very thankful!
Manoj
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Manoj,
I have seen ur request to get the ans. to this ques. in another thread. It's my sincere request that please keep different threads totally isolated if they r not related. Please follow the same thread. Also bear in mind that people here r taking extra pains to reply/help others. If different threads get mixed up then it will be a waste of their valuable time to check a thread just to mind that it has been messed up.
Also if u don;t get reply just put another reminder may be after 5-6 days on the same thread. People here r really nice.
About the reply i'll check 2Morrow. right now it's already midnight here.
Hope am not harsh.
 
Manoj Tare
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both threads are same .
On first one i did some R and D then i got second problem .
so i send second one
that it .
thanxs
 
Ashish Mahajan
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Manoj,
I haven't worked out on ur prob. First should we look with other sol. may be adding JLabel component with image to the scroll pane. like this :-
new JScrollPane().add(new JLabel(new ImageIcon("myimage.jpg")));
Let us know. so that we can better figure out the sol.
 
Manoj Tare
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ashish ,
I got exactly where the problem is .
But i don't know solution.
The problem is with setPerferredSize(new Dimension(width,height))
Using this method we can set size for component , on my application i'm setting Jpanel size but it doesn't change the original size .
I don't know where exaclty i'm doing mistake.
Following is method called after clikcing zoomIn button .

public void zoomImage(ZoomImage zoom){
BufferedImage newImg = zoom.zoomIn(this.buffImage);
this.buffImage = newImg;
this.setPreferredSize(new Dimension(newImg.getWidth(),newImg.getHeight()));
this.revalidate();

this.repaint();
}

After this when i check the panel size in paintComponent(Graphics g) method , it should be change . But it's not changing.
thanks
Manoj
 
Manoj Tare
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ashish ,
yahooooooooooooo.........
I got solution ,

In my applciation class implements Scrollable interface so its deafult preferedSize .
If i add new one then only it takes old .
after make changes (width and height on panel) in scorble method it works fine.
thanks for do interst in my problem
keep in touch
Manoj
 
Politics is a circus designed to distract you from what is really going on. So is this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic