i am using Jtree for image list and displaying the selected image, but problem is that if the image size is larger than the canvas size(i.e. 300 X 300) it displays only top left of the image, how to display the whole image in fixed size canvas?
i am using following code:
private void displayImage(File file) {
try
{
BufferedImage image = ImageIO.read(file);
ta.Picture = image;
}
catch (Exception e)
{}
Graphics g = ta.imageCanvas.getGraphics();
g.clearRect(0, 0, 300, 300);
g.drawImage(ta.Picture, 00, 00, this);
} // displayImage
public void valueChanged(TreeSelectionEvent e)
{
// TODO Auto-generated method stub
FileTreeNode node = (FileTreeNode) tree.getLastSelectedPathComponent();
if (node.isLeaf())
{
currentFile = node.file;
File ff = new File("F:/images_blue/" + currentFile.getName());
displayImage(ff);
} else
currentFile = null;
}