• Post Reply Bookmark Topic Watch Topic
  • New Topic

JScrollPane  RSS feed

 
Manoj Tare
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Ashish Mahajan
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!