how to set image to a jpanel
i have a swing application where i have to load an image and do some annotations on it. the application contains two toolbars. one toolbar contains buttons such as loading an image,zoom in,zoom out etc. other toolbar contains buttons such as drawing circles,rectangles on the image. so what i did is i have added these two toolbars to two separate panels and added it to frame. first frame as horizontal panel and added to the north of frame and second toolbar as vertical panel added to the west. now i declared the remaining part of the frame as third panel where the actual image is seen and can be modified. my problem is if the image is small it is showing the image in the center and if the image is big it is added with the scrollbar which i provided. i want to change the size of this panel whenever i add an image to this panel either a big image or a small. i mean i want to assign the size of the image to the size of the panel. hope you understand my problem...........i cannot load the code as it is huge one.